2009-03-05 60 views
0

我們正在向.Net 3.5 ASMX Web服務發送以下請求。ASMX WebServices問題

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
    <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
     <Login xmlns="http://tempuri.org/" id="o0" SOAP-ENC:root="1"> 
      <password xsi:type="xsd:string">1234</password> 
      <userName xsi:type="xsd:string">Developer</userName> 
     </Login> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope>  


在調試,web服務,我們發現,可用於網絡方法(登錄和方法)的parametr值爲空。 但是,如果我們從密碼和用戶名中刪除xsi:type =「xsd:string」屬性,則一切正常。
命名空間xsd指向http://www.w3.org/2001/XMLSchema,它是有效的。
爲什麼不能.Net反序列化響應?爲什麼它不拋出異常? BTW:我們的服務定義別名http://www.w3.org/2001/XMLSchema爲「s」。這可能是一個問題嗎?

親切的問候,

+0

是爲在Stack Overflow上的可讀性添加的
標記,還是它們是你信封的一部分? – RuudKok 2009-03-05 10:07:08

+0

爲了便於閱讀,增加:) – 2009-03-05 10:52:04

回答

1

NET序列化程序依靠底層架構來反序列化的東西。當您指定xsi:type屬性時,您基本上會中斷模式合約。

順便說一句。不要使用http://tempuri.org/,組成你自己的URI。

+0

Thx。但爲什麼它會破裂?我們已經指定了xsd,它指向http://www.w3.org/2001/XMLSchema。所以這應該是有效的。 – 2009-03-05 11:55:00

1

您的ASMX服務是用[SoapRpcService]屬性裝飾的嗎?如果不是,那麼它是一個文檔/文字服務,並且不需要那種格式的XML。

XML是如何發送的?它是用手建造的嗎?是否由基於從「service.asmx?WSDL」派生的WSDL創建的Java客戶端發送?