检查C#中phpsoap是否返回soapFault
我在检查 PHP Soap Web 服务中写入的 SoapFault 响应时遇到问题。 响应看起来像这样(默认“抛出新的SoapFault(“SOAP:CLIENT”,“错误登录”);”
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP:CLIENT</faultcode>
<faultstring>Bad login</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
并且C#代码看起来像这样:
try
{
//creating new webservice, filling headers and alling something
webservice = new...
items = webservice.getSth();
}
catch ( Exception ex )
{
MessageBox.Show(ex.Message); -> "Namespace prefix 'SOAP' not defined"
}
当登录/通过/apikey等没问题时,我得到了我需要的东西,但是当某事是错误的,我无法显示正确的信息。
如何检查 SOAP 是否返回错误? 我用谷歌搜索了这个问题,但找不到有价值的信息。
不幸的是我无法更改网络服务。
感谢您的任何帮助。
I have problem with checking SoapFault response from writen in PHP Soap webservice.
Responce looks like this (default "throw new SoapFault("SOAP:CLIENT", "Bad login");"
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP:CLIENT</faultcode>
<faultstring>Bad login</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
And C# code looks like this:
try
{
//creating new webservice, filling headers and alling something
webservice = new...
items = webservice.getSth();
}
catch ( Exception ex )
{
MessageBox.Show(ex.Message); -> "Namespace prefix 'SOAP' not defined"
}
When login/pass/apikey etc is OK than i get what i need, but when sth is wrong than i cant display proper information.
How to check if SOAP returned fault?
I googled for the problem, but couldnt find valuable information.
Unfortunetly i cant change webservice.
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)