6

我正在尝试通过 WCF 从 .NET 使用 SAP Web 服务。我已经生成了代理并配置了 app.config 文件。

这是我的测试代码:

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>

我不知道会发生什么。有任何想法吗?

提前致谢

4

1 回答 1

3

顺便说一下,当您创建代理时(顺便说一句,您使用什么技术来做到这一点?),SAP 告诉 .NET 参数和响应将位于某个命名空间中,但是您将参数发送到空命名空间(“”)。这可能是 SAP 服务返回“结果:”的原因。您可能会收到空响应,因为您的代理可能期望 TestOutput 元素位于不同的命名空间中。

查看生成的代理类并查看预期的名称空间。

于 2010-11-15T20:42:14.577 回答