2008-08-17 43 views
0

我有一個.net Web應用程序,該Web應用程序在頁面中嵌入了一個Flex應用程序。這個flex應用程序調用.net webservice。我可以通過調試跟蹤執行proccess,直到我得到的迴應都看起來不錯:SoapException:在從Flex調用.NET Web服務時缺失根元素




soap:ReceiverSystem.Web.Services.Protocols.SoapException: Server was unable to process request 

. ---> System.Xml.XmlException: Root element is missing. 

    at System.Xml.XmlTextReaderImpl.Throw(Exception e) 

    at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res) 

    at System.Xml.XmlTextReaderImpl.ParseDocumentContent() 

    at System.Xml.XmlTextReaderImpl.Read() 

    at System.Xml.XmlTextReader.Read() 

    at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read() 

    at System.Xml.XmlReader.MoveToContent() 

    at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.MoveToContent() 

    at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement() 

    at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest() 

    at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) 

    at System.Web.Services.Protocols.SoapServerProtocol.Initialize() 

    at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest 

request, HttpResponse response, Boolean& abortProcessing) 

    --- End of inner exception stack trace --- 
 

從Flex中調用看起來不錯,通過web服務的執行是好的,但是這是我通過Wireshark的捕獲響應, 這裏發生了什麼?

我嘗試了好幾種Web方法,從「你好世界」 paramatized方法......所有復出相同的反應......

我認爲它可能是與編碼與「 - - & gt「,但我不確定如何控制.net渲染作爲響應。

回答

1

看起來你可能會發送一個格式不完整的XML文檔到服務。你可以使用Fiddler或類似的東西來獲得去往Web服務的實際調用的副本嗎?這將幫助我們找出問題所在。

+0

如果請求格式錯誤,我不認爲我會看到正常執行通過web服務與調試器...我會嗎? – mmattax 2008-08-19 12:32:58

0

您使用Flex 3嗎?如果是這樣,你可以在web服務執行時設置一個斷點,並且在它編碼你的請求時實際上遍歷Flex框架。看看mx.rpc.soap.SoapEncoder,你就可以看到準確地發送了什麼。

1

我最近使用了一個.NET REST接口,我使用Flex應用程序進行了消費。我也遇到了一些奇怪的異常,我的問題是我在發送請求時忘記在根元素中包含xmlns(名稱空間)。這是一個瘋狂的猜測,但我希望它有幫助。