6
我正嘗試從.NET通過WCF使用SAP Web服務。我已經生成了代理,並且已經配置了app.config文件。通過WCF從.NET獲得SAP Web服務
這裏是我的測試代碼:
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();
的ZTestRFC SAP方法是非常簡單的函數,它接受一個輸入字符串,並輸出:"Result: <the input string>"
當我打電話ZTestRFC方法,我得到了一個空變量響應中的值。但是SOAP消息似乎很好。
SOAP請求
<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響應
<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>
我不知道什麼可能會發生。有任何想法嗎?
在此先感謝
謝謝你的回答約翰。我用VS2008來生成代理類。我檢查了代理中定義的命名空間,但目前我還沒有成功:_(我會給你反饋 – Javier 2010-11-16 10:34:33
@Javier:你使用「添加Web引用」,「添加服務引用」或什麼? – 2010-11-16 19:09:17
我使用添加服務引用與wsdl URL。謝謝 – Javier 2010-11-17 00:29:50