![](/img/trans.png)
[英]Why am I getting org.xml.sax.SAXException for this block of XML?
[英]consuming SOAP in ASP.Net: org.xml.sax.SAXException: …could not find deserializer for type
我正在尝试从https://secure.ultracart.com/axis/services/AffiliateServiceV1?wsdl在ASP.Net(C#)中使用SOAP Web服务WSDL
因此,在Asp.Net中的Visual Studio 2008中,我右键单击并单击“添加Web引用...”,然后将其输入WSDL URL,并通过接缝将其添加到项目中,并在IntelliSense中正常显示类,因此我写下面的代码:
using com.ultracart.secure;
var affiliateService = new AffiliateServiceService();
var cridtials = new Credentials() { login = "username", password = "password", merchantId = "MERID", };
var resultAffiliate = affiliateService.getAffiliateByEmail(cridtials, "email@example.com");
并尝试运行它,但出现此错误:
org.xml.sax.SAXException: Deserializing parameter 'c': could not find deserializer for type {http://v1.ultraship.soap.api.ultracart.bpsinfo.com}Credentials
Exception Details: System.Web.Services.Protocols.SoapException: org.xml.sax.SAXException: Deserializing parameter 'c': could not find deserializer for type {http://v1.ultraship.soap.api.ultracart.bpsinfo.com}Credentials
Source Error:
Line 239: [return: System.Xml.Serialization.SoapElementAttribute("getAffiliateByEmailReturn")]
Line 240: public Affiliate getAffiliateByEmail(Credentials c, string email) {
Line 241: object[] results = this.Invoke("getAffiliateByEmail", new object[] {
Line 242: c,
Line 243: email});
Source File: c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\website1\f651361a\a12a13b7\App_WebReferences.juj3lvko.0.cs Line: 241
Stack Trace:
[SoapException: org.xml.sax.SAXException: Deserializing parameter 'c': could not find deserializer for type {http://v1.ultraship.soap.api.ultracart.bpsinfo.com}Credentials]
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +431714
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +204
com.ultracart.secure.AffiliateServiceService.getAffiliateByEmail(Credentials c, String email) in c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\website1\f651361a\a12a13b7\App_WebReferences.juj3lvko.0.cs:241
Class1.makeaff() in c:\Users\~\Documents\Visual Studio 2008\WebSites\WebSite1\App_Code\Class1.cs:25
Handler.ProcessRequest(HttpContext context) in c:\Users\~\Documents\Visual Studio 2008\WebSites\WebSite1\Handler.ashx:10
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
我的问题是,在向服务器发出请求并且服务器返回了某些内容后,此错误发生了吗?或者它是无效的? ...当然可以做些什么使它正常工作?
我即将准备实现自己的接口来解析xml并发送/接收正确的响应...
我在互联网上发现了相同类型的错误,但是没有一个接缝可以回答它们……在创建新的AffiliateServiceService()的实例时我应该做些什么? ?
我以前从未使用过SOAP,但是我在网络上查看了许多示例,因此不应发生此错误。
非常感谢您的帮助! 我真的希望我知道asp.net中的“ Web参考”实际上是如何工作的(即,.net背后的代码),谢谢!
.Net Framework很难在其自动代理生成中反序列化Axis类。 本文可能会有所帮助。 它讨论了使用自定义肥皂分析器手动处理此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.