6

I'm trying to consume a SAP Web Service from .NET via WCF. I've generated the proxy and I have configured the app.config file.

Here is my test code:

WebServiceSAP.ZTEST_RFCClient myWCFService = new WebServiceSAP.ZTEST_RFCClient("MyEndPoint");

myWCFService.ClientCredentials.UserName.UserName = "<UserName>";
myWCFService.ClientCredentials.UserName.Password = "<Password>";

WebServiceSAP.ZTestRfc parameter = new WebServiceSAP.ZTestRfc();
parameter.TestInput = "This is a simple test";

WebServiceSAP.ZTestRfcResponse response = myWCFService.ZTestRfc(parameter);

Console.WriteLine(reponse.TestOutput);
Console.ReadLine();            

The ZTestRFC SAP method is a very simple function that accepts an input string, and outputs: "Result: <the input string>"

When I call ZTestRFC method, I got a null value in variable response. But SOAP messages seem to be fine.

SOAP Request

<MessageLogTraceRecord>
<HttpRequest xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<Method>POST</Method>
<QueryString></QueryString>
<WebHeaders>
<VsDebuggerCausalityData>uIDPoxJmI5NcDatNiPM/wFAr52kAAAAAtqHAVnNWjEeMpMExOyr/vN7OXwCJZltNnikldpg5migACQAA</VsDebuggerCausalityData>
</WebHeaders>
</HttpRequest>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">urn:sap-com:document:sap:soap:functions:mc-style:ZTEST_RFC:ZTestRfcRequest</Action>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ZTestRfc xmlns="urn:sap-com:document:sap:soap:functions:mc-style">
<TestInput xmlns="">This is a simple test</TestInput>
</ZTestRfc>
</s:Body>
</s:Envelope>
</MessageLogTraceRecord>

SOAP Response

<MessageLogTraceRecord>
<HttpResponse xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<StatusCode>OK</StatusCode>
<StatusDescription>OK</StatusDescription>
<WebHeaders>
<Content-Length>359</Content-Length>
<Content-Type>text/xml; charset=utf-8</Content-Type>
<Set-Cookie>MYSAPSSO2=AjExMDABAAxQMDEwMDA1MSAgICACAAMwNDADAAhEMTEgICAgIAQADDIwMTAxMTEwMTIwOQUABAAAAAgGAAFYCQABU%2f8A9jCB8wYJKoZIhvcNAQcCoIHlMIHiAgEBMQswCQYFKw4DAhoFADALBgkqhkiG9w0BBwExgcIwgb8CAQEwEzAOMQwwCgYDVQQDEwNQMTECAQAwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTEwMTExMDEyMDk0OFowIwYJKoZIhvcNAQkEMRYEFJC%2fNFLVBnu1ZAodWTlPApEs8sApMAkGByqGSM44BAMEMDAuAhUBS844BOB%2f8NgEGuepMgLaKbVEGGUCFQFLs6HiI%21BWT1MejMqvABd3%2fJFVMw%3d%3d; path=/; domain=.<domain ... ></Set-Cookie>
<Server>SAP NetWeaver Application Server / ABAP 700</Server>
</WebHeaders>
</HttpResponse>
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"></s:Header>
<SOAP-ENV:Body>
<rfc:ZTestRfcResult xmlns:rfc="urn:sap-com:document:sap:soap:functions:mc-style">
<TestOutput xmlns="">Result:</TestOutput>
</rfc:ZTestRfcResult>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</MessageLogTraceRecord>

I don't know what could be happening. Any ideas?

Thanks in advance

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Javier
  • 4,051
  • 2
  • 22
  • 20

1 Answers1

3

Offhand, it looks like when you created the proxy (BTW, what technique did you use to do that?), SAP told .NET that the parameter and the response would be in some namespace, but that you're sending the parameter in the empty namespace (""). That may be why the SAP service is returning "Result:". You may be getting a null response because your proxy may be expecting the TestOutput element to be in a different namespace.

Look at the generated proxy classes and see what namespaces are expected.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • Thanks for your answer John. I've used VS2008 to generate the proxy classses. I've checked out namespaces defined in the proxy, but at the moment I have not been successful :_( I'll give you feedback – Javier Nov 16 '10 at 10:34
  • @Javier: did you use "Add Web Reference", "Add Service Reference", or what? – John Saunders Nov 16 '10 at 19:09
  • I used Add service referente with the wsdl URL. Thanks – Javier Nov 17 '10 at 00:29
  • I've used VS2003 and SAP .NET Connector 2.0 and it works fine. Anyway, I'll keep trying to solve my problem in VS2008. – Javier Nov 18 '10 at 10:29
  • @Javier: "Add Service Reference" is the correct technology to use. Look carefully at the Reference.cs file and learn to understand what's in it. In particular, look at the namespaces specified. – John Saunders Nov 18 '10 at 19:15
  • Hi @John, It's been a long time :-) Just tell that finally I couldn't consume de SAP service using WCF, and I had to use a SAP Connector component to make this work. I still don't know why :-) But thanks very much for your help! – Javier Mar 09 '12 at 08:34