我试图使用提供给我的WSDL文件来调用服务。我收到“意外的数据包格式”错误。我已经使用SOAPUI测试了服务,一切都在那里工作。当我从C#应用程序调用服务时,我得到上面引用的错误。
相关信息
码
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:无法解析远程名称:System.Net上的System.Net.HttpWebRequest.GetRequestStream()处的System.Net.HttpWebRequest.GetRequestStream(TransportContext&context)中的'r3snd.yaskawa.com'。 ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()---内部异常堆栈跟踪结束---
服务器堆栈跟踪:System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message消息,TimeSpan超时)System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan超时)System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan超时)在System.ServiceModel.Channels.ServiceChannel.Call( System.ServiceModel.Channels.ServiceChannelProxy.Invoke上的System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime操作)中的String action,Boolean oneway,ProxyOperationRuntime操作,Object [] ins,Object [] outs,TimeSpan timeout) IMessage消息)
在[0]处重新抛出异常:位于ServicesFromSAP.TableReference的System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&msgData,Int32类型)的System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)。在用C ServicesFromSAP.TableReference.ZPC_DROP_DOWN_VALUESClient.ServicesFromSAP.TableReference.ZPC_DROP_DOWN_VALUES.ZpcDropDownValues(ZpcDropDownValuesRequest请求)ZPC_DROP_DOWN_VALUES.ZpcDropDownValues(ZpcDropDownValuesRequest请求):\用户\ eric_obermuller \源\回购\ ServicesFromSAP \ ServicesFromSAP \连接服务\ TableReference \ Reference.cs:服务FromSAP.Program.Main(String []中的服务FromSAP.TableReference.ZPC_DROP_DOWN_VALUESClient.ZpcDropDownValues(ZpcDropDownValues ZpcDropDownValues1)中的第339行:C:\ Users \ eric_obermuller \ source \ repos \ ServicesFromSAP \ ServicesFromSAP \ Connected Services \ TableReference \ Reference.cs:第345行] args)在C:\ Users \ eric_obermuller \ source \ repos \ ServicesFromSAP \ ServicesFromSAP \ Program.cs:lin e 33
我不确定是什么问题。这项服务是为了测试/学习目的而提供给我的,所以我可以开始学习如何使用他们的服务。有什么样的设置我不知道吗?
任何建议将不胜感激。不确定我是否需要将超时设置为更长或沿着这些行。我到处寻找答案,似乎这是一个案例问题。
好吧我弄明白了这个问题。最初在测试此应用程序时,请求实际上是作为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 Transport
<httpsTransport authenticationScheme="Basic" />
Http Transport(正确的)
<httpTransport authenticationScheme="Basic" />
我希望这可以帮助其他人下线,因为它让我疯了!
谢谢大家查看我的问题。