我正在尝试在ASP.Net中使用SOAP Web服务WSDL(C#) 来自https://secure.ultracart.com/axis/services/AffiliateServiceV1?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 Referances”实际上是如何工作的(即.net的代码背后),谢谢!
答案 0 :(得分:0)
.Net Framework很难在其自动代理生成中反序列化Axis类。这篇文章可能有帮助。它讨论了使用自定义soap解析器手动处理它。