![](/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.