我试图使用提供给我的WSDL文件来调用服务。我收到“意外的数据包格式”错误。我已经使用SOAPUI测试了服务,并且一切都从那里开始。当我从C#应用程序调用服务时,出现上述错误。

相关资料


由SAP提供服务
服务是使用.WSDL文件导入的
在控制台应用程序中测试
我已经测试了我的SAP小组提供的其他服务,这些服务运行良好。




ZPC_DROP_DOWN_VALUESClient client = new ZPC_DROP_DOWN_VALUESClient();
client.ClientCredentials.UserName.UserName = "ERICO";
client.ClientCredentials.UserName.Password = "Password";
ZpcDropDownValues vals = new ZpcDropDownValues();
vals.Uom = "X";
ZpcDropDownValuesResponse Response = new ZpcDropDownValuesResponse();

try
{
    Response = client.ZpcDropDownValues(vals);
}
catch (Exception ex)
{
    Console.WriteLine(ex.ToString());
}
Console.ReadKey();


这是堆栈跟踪:


  System.ServiceModel.EndpointNotFoundException:没有侦听https://r3snd.yaskawa.com:8000/sap/bc/srt/rfc/sap/zpc_drop_down_values/410/zpc_drop_down_values/zpc_drop_down_values的终结点可以接受该消息。这通常是由不正确的地址或SOAP操作引起的。有关更多详细信息,请参见InnerException(如果存在)。 ---> System.Net.WebException:无法解析远程名称:“ r3snd.yaskawa.com”
     在System.Net.HttpWebRequest.GetRequestStream(TransportContext&context)
     在System.Net.HttpWebRequest.GetRequestStream()
     在System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
     ---内部异常堆栈跟踪的结尾---
  
  服务器堆栈跟踪:
     在System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
     在System.ServiceModel.Channels.HttpOutput.Send(TimeSpan超时)
     在System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(消息,TimeSpan超时)
     在System.ServiceModel.Channels.RequestChannel.Request(消息,TimeSpan超时)
     在System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息,TimeSpan超时)
     在System.ServiceModel.Channels.ServiceChannel.Call处(字符串操作,布尔单向,ProxyOperationRuntime操作,Object [] ins,Object [] outs,TimeSpan超时)
     在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime操作)
     在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage消息)
  
  异常重新抛出为[0]:
     在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)
     在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&msgData,Int32类型)
     在ServicesFromSAP.TableReference.ZPC_DROP_DOWN_VALUES.ZpcDropDownValues(ZpcDropDownValuesRequest请求)
     在C:\ Users \ eric_obermuller \ source \ repos \ ServicesFromSAP \ ServicesFromSAP \ Connected Services \ TableReference中的C:\ Users \ eric_obermuller \ source \ repos \ ServicesFromSAP \ ServicesFromSAP \ Connected Services \ TableReference中:ServicesFromSAP.TableReference.ZPC_DROP_DOWN_VALUESClient.ServicesFromSAP.TableReference.ZPC_DROP_DOWN_VALUES.ZpcDropDownValues(ZpcDropDownValuesRequest request)
     位于C:\ Users \ eric_obermuller \ source \ repos \ ServicesFromSAP \ ServicesFromSAP \ Connected Services \ TableReference \ Reference.cs:第345行的ServicesFromSAP.TableReference.ZPC_DROP_DOWN_VALUESClient.ZpcDropDownValues(ZpcDropDownValues ZpcDropDownValues1)
     在C:\ Users \ eric_obermuller \ source \ repos \ ServicesFromSAP \ ServicesFromSAP \ Programs.cs:line 33中的ServicesFromSAP.Program.Main(String [] args)处


我不确定是什么问题。该服务是为测试/学习目的提供给我的,因此我可以开始学习如何使用他们的服务。有我不知道的某种设置吗?

任何建议将不胜感激。不知道我是否需要将超时设置为更长或更类似的时间。我到处都在寻找答案,这似乎是个案问题。

最佳答案

好吧,我知道了这个问题。最初,在测试此应用程序时,该请求实际上是作为Http请求发送给我的。

App.Config中的端点

<endpoint address="http://R3SND.yaskawa.com:8000/sap/bc/srt/rfc/sap/zpc_drop_down_values/410/zpc_drop_down_values/zpc_drop_down_values"
            binding="customBinding" bindingConfiguration="ZPC_DROP_DOWN_VALUES"
            contract="TableReference.ZPC_DROP_DOWN_VALUES" name="ZPC_DROP_DOWN_VALUES" />


当我尝试该应用程序时,出现错误消息“无效的URI Http,预期为Https”。我不知道发生了什么,所以将端点地址更改为Https而不是Http。那就是上面提到的错误发生的地方。

在弄乱时,我将其改回了Http,并意识到由于我使用的是HttpsTransport而不是HttpTransport,因此引发了错误。

Https传输

<httpsTransport authenticationScheme="Basic" />


Http Transport(正确的一种)

<httpTransport authenticationScheme="Basic" />


我希望这可以帮助其他人,因为它使我发疯!

谢谢大家看我的问题。

10-07 13:59
查看更多