Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: C# .NET + NuSOAP
Forum PHP.pl > Forum > PHP
markac
Witam.
Stworzyłem pewną usługę wykorzystując bibliotekę NuSOAP w PHP. Klient jest stworzony w C# i ładnie to działa, wywołuje poprawnie funkcje i otrzymuje wyniki. Problem pojawia się wtedy, kiedy postanowię zwrócić wyjątek do klienta:

  1. <?php
  2. return new nusoap_fault('Client', '', 'bla bla', 'bla bla');
  3. ?>


Klient zgłasza wyjątek (Exception detail):

Cytat
System.ServiceModel.CommunicationException was unhandled
Message="Server returned an invalid SOAP Fault. Please see InnerException for more details."
Source="mscorlib"
StackTrace:
Server stack trace:
w System.ServiceModel.Channels.MessageFault.CreateFault(Message message, Int32 maxBufferSize)
w System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
w System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
w System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
w System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessag
methodCall, ProxyOperationRuntime operation)
w System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
w System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
w System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
w WideCMS.WideCMSService.WideCMSPortType.LogIn(String username, String password)
w WideCMS.WideCMSService.WideCMSPortTypeClient.LogIn(String username, String password) w C:\Documents and Settings\markac\Moje dokumenty\Visual Studio 2008\Projects\WideCMS\WideCMS\Service References\WideCMSService\Reference.cs:wiersz 52
w WideCMS.Form1.button1_Click(Object sender, EventArgs e) w C:\Documents and Settings\markac\Moje dokumenty\Visual Studio 2008\Projects\WideCMS\WideCMS\Form1.cs:wiersz 31
w System.Windows.Forms.Control.OnClick(EventArgs e)
w System.Windows.Forms.Button.OnClick(EventArgs e)
w System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
w System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
w System.Windows.Forms.Control.WndProc(Message& m)
w System.Windows.Forms.ButtonBase.WndProc(Message& m)
w System.Windows.Forms.Button.WndProc(Message& m)
w System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
w System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
w System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
w System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
w System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNat
veMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
w System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
w System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
w System.Windows.Forms.Application.Run(Form mainForm)
w WideCMS.Program.Main() w C:\Documents and Settings\markac\Moje dokumenty\Visual Studio 2008\Projects\WideCMS\WideCMS\Program.cs:wiersz 18
w System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
w System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
w Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
w System.Threading.ThreadHelper.ThreadStart_Context(Object state)
w System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
w System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Xml.XmlException
Message="Nie można odnaleźć elementu 'faultstring' z nazwą obszaru nazw ''. Wiersz 6, pozycja 117."
Source="System.Xml"
LineNumber=6
LinePosition=117
StackTrace:
w System.Xml.XmlReader.CheckElement(String localName, String namespaceURI)
w System.Xml.XmlReader.ReadElementContentAsString(String localName, String namespaceURI)
w System.ServiceModel.Channels.ReceivedFault.CreateFault11(XmlDictionaryReader reader, Int32 maxBufferSize)
w System.ServiceModel.Channels.MessageFault.CreateFault(Message message, Int32 maxBufferSize)
InnerException:


Najważniejsze rzeczy zaznaczyłem pogrubioną czcionką. Nie wiem dlaczego tak się dzieje. Stworzyłem dla testu usługę w ASP C#:

Cytat
throw new SoapException("bla bla", SoapException.ClientFaultCode);


i to działa. Zastanawiam się, czy NuSoap nie posiada jakiegoś buga? Z góry dzięki za pomoc.
em1X
Po co korzystać z nuSOAP, skoro php ma własną bibliotekę obsługi SOAP ? smile.gif
markac
Bo żeby wygenerować wrappera dla C#, potrzebuję plik WSDL, a wbudowana klasa w PHP takowego nie generuje. Mam go ręcznie pisać? :-)

---------------
Problem rozwiązany. Niestety dodawanie usługi przez Add Service Reference w projekcie C# nie zdaje egzaminu. Trzeba ręcznie generować kod cs:
Cytat

Wygenerowany plik cs należy potem dodać do projektu. Niestety jest to dość kłopotliwe, jeśli zajdzie potrzeba zaktualizowania kodu klienta. Zyskujemy natomiast możliwość asynchronicznego wywoływania funkcji.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.