我有一个项目文件,我已经使用 SOAP UI 对其进行了测试。
现在我想写它的客户端所以通过查看这个solution https://stackoverflow.com/a/4791932/8919244我尝试过把事情做好。但我有一个问题。
在解决方案中,URL
and action
被提到。我有一个URL
但我不确定什么是我的action URL
。所以我把两者都放在一起。
var _url = "http://111.111.111.1:111/HES/services/DoCommandRequest";
var _action = "http://111.111.111.1:111/HES/services/DoCommandRequest";
XmlDocument soapEnvelopeXml = CreateSoapEnvelope();
HttpWebRequest webRequest = CreateWebRequest(_url, _action);
InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);
// begin async call to web request.
IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);
// suspend this thread until call is complete. You might want to
// do something usefull here like update your UI.
asyncResult.AsyncWaitHandle.WaitOne();
// get the response from the completed web request.
string soapResult;
using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
{
using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
{
soapResult = rd.ReadToEnd();
}
Console.Write(soapResult);
}
运行我的代码后,我收到一个异常using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
其中说
系统.Net.WebException
{“远程服务器返回错误:(500) 内部服务器错误。”}
我相信我的方法有问题action
,但我不确定。
任何帮助将不胜感激。
SOAPAction 在 SOAP 1.1 中是必需的,但可以为空 ("")。请参阅此处的评论 https://stackoverflow.com/a/36494862/8978576
首先,您应该尝试使用 wsdl 文件的链接创建新的 SOAP 项目。之后尝试从 SOAP UI 发出请求。尝试运行“doCommand”操作。看看结果。您可以将其与应用程序的请求进行比较。您还可以使用 Fiddler 来截取您的请求并进行比较以找出差异。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)