Einzelnen Beitrag anzeigen

Zottel
(Gast)

n/a Beiträge
 
#4

Re: Mit W32 Delphi auf C# WCF zugreifen? Erfahrungen?

  Alt 9. Nov 2008, 11:47
So. Nun habe ich das ganze Projekt nochmal aufgesetzt und diesmal so, das ich vernünftige Fehlermeldungen bekomme.

Der C# WCF-Service hat einen Server und einen Client, die einwandfrei zusammenarbeiten. Den Protokollverkehr habe ich rausgesucht:

Delphi-Quellcode:
POST /WCFMaster/ HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/IJNDemoService/echoString"
Host: 192.168.100.110:1973
Content-Length: 172
Expect: 100-continue

HTTP/1.1 100 Continue

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
 <s:Body>
  <echoString xmlns="http://tempuri.org/">
   <Value>TestString</Value>
  </echoString>
 </s:Body>
</s:Envelope>

HTTP/1.1 200 OK
Content-Length: 210
Content-Type: text/xml; charset=utf-8
Server: Microsoft-HTTPAPI/1.0
Date: Sun, 09 Nov 2008 10:44:23 GMT

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
 <s:Body>
  <echoStringResponse xmlns="http://tempuri.org/">
   <echoStringResult>TestString</echoStringResult>
  </echoStringResponse>
 </s:Body>
</s:Envelope>
Dieser Ausschnitt beinhaltet die Clientanfrage und die Serverantwort.

Wenn ich nun einen Delphi-Client mit D2006 aufsetze und mit eine Unit, zum zugreifen auf den WCF-Service, mit dem WSDL-Import erzeugen lasse,
Dann scheint er zumindest bei mit dem WCF-Service anzufrage. Aber der versteht nur bahnhof und gibt entsprechende Fehlermeldung raus:
Zitat:
---------------------------
Benachrichtigung über Debugger-Exception
---------------------------
Im Projekt WCFSniffer.exe ist eine Exception der Klasse ERemotableException mit der Meldung 'Error in deserializing body of request message for operation 'echoString'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'echoString' and namespace 'http://tempuri.org/'. Found node type 'Element' with name 'parameters' and namespace ''' aufgetreten.
---------------------------
Anhalten Fortsetzen Hilfe
---------------------------
Den Transportverkehr habe ich auch rausgesucht:
Delphi-Quellcode:
POST /WCFMaster/ HTTP/1.1
SOAPAction: "http://tempuri.org/IJNDemoService/echoString"
Content-Type: text/xml
User-Agent: Borland SOAP 1.2
Host: 192.168.100.110:1973
Content-Length: 379
Connection: Keep-Alive
Cache-Control: no-cache

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <parameters xsi:type="xsd:string">test</parameters>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

HTTP/1.1 500 Internal Server Error
Content-Length: 2371
Content-Type: text/xml; charset=utf-8
Server: Microsoft-HTTPAPI/1.0
Date: Sun, 09 Nov 2008 11:24:44 GMT

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
 <s:Body>
  <s:Fault>
   <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode>
   <faultstring xml:lang="de-DE">Error in deserializing body of request message for operation 'echoString'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Elementwith name 'echoStringand namespace 'http://tempuri.org/'. Found node type 'Elementwith name 'parametersand namespace ''</faultstring>
   <detail>
    <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
     <HelpLink i:nil="true"/>
     <InnerException>
      <HelpLink i:nil="true"/>
      <InnerException i:nil="true"/>
      <Message>OperationFormatter encountered an invalid Message body. Expected to find node type 'Elementwith name 'echoStringand namespace 'http://tempuri.org/'. Found node type 'Elementwith name 'parametersand namespace ''</Message>
      <StackTrace> at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRequest(XmlDictionaryReader reader, Object[] parameters)&#xD;
         at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRequest(Message message, Object[] parameters)</StackTrace>
      <Type>System.Runtime.Serialization.SerializationException</Type>
     </InnerException>
     <Message>Error in deserializing body of request message for operation 'echoString'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Elementwith name 'echoStringand namespace 'http://tempuri.org/'. Found node type 'Elementwith name 'parametersand namespace ''</Message>
     <StackTrace> at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRequest(Message message, Object[] parameters)&#xD;
        at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc)&#xD;
        at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)&#xD;
        at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)&#xD;
        at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
     <Type>System.ServiceModel.CommunicationException</Type>
   </ExceptionDetail>
  </detail>
  </s:Fault>
 </s:Body>
</s:Envelope>
Scheint so, als verstünde C# die Delphi-Anforderung nicht. Oder habe ich etwas verkehrt gemacht?
Angeblich soll WCF ja einen normalen SOAP-Dienst darstellen können.

Eine andere Alternative wäre auch noch, das ich das ganze per Hand Parse und die anfragen und Antworten selbst auseinanderpflücke. Aber das möchte ich mir gerne ersparen.
  Mit Zitat antworten Zitat