2011-03-02 106 views
2

我正在尋找有關在Visual Studio 2010中使用add service reference創建的Web服務客戶端調用Web服務並返回結果時會發生什麼情況的信息。肥皂信封是如何生成的?爲什麼.NET和php客戶會生成/接收不同的肥皂信封?

肥皂請求信封是如何創建的以及什麼決定了格式? 如何創建肥皂響應信封並確定格式?

這個過程總是被.net抽象掉,我從來沒有看過它是如何完成的,但我們有一個用戶使用php,似乎與響應信封有問題。下面我將提供請求的SOAP信封示例以及.net和php代碼的響應。

PHP請求:

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:ns1="http://some.junk.url.xxxx.com"> 
    <SOAP-ENV:Body> 
    <ns1:wsActionRouter> 
     <ns1:i_UserId>XXXX</ns1:i_UserId> 
     <ns1:i_Password>******</ns1:i_Password> 
     <ns1:ActionType>CS</ns1:ActionType> 
     <ns1:XmlData> 
     blah blah blah 
     </ns1:XmlData> 
    </ns1:wsActionRouter> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

.NET請求:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Header> 
    <Action s:mustUnderstand="1" 
     xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none" /> 
    </s:Header> 
    <s:Body> 
    <wsActionRouter xmlns="http://some.junk.url.xxxx.com"> 
     <i_UserId>XXXX</i_UserId> 
     <i_Password>******</i_Password> 
     <ActionType>CS</ActionType> 
     <XmlData> 
     blah blah blah 
     </XmlData> 
    </wsActionRouter> 
    </s:Body> 
</s:Envelope> 

PHP響應:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soapenv:Header/> 
    <soapenv:Body> 
    <p287:wsActionRouterResponse xmlns:p287="http://some.junk.url.xxxx.com"> 
     <p287:wsActionRouterReturn> 
     blah blah blah 
     </p287:wsActionRouterReturn> 
    </p287:wsActionRouterResponse> 
    </soapenv:Body> 
</soapenv:Envelope> 

.NET響應:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soapenv:Header /> 
    <soapenv:Body> 
    <wsActionRouterResponse xmlns="http://some.junk.url.xxxx.com"> 
     <wsActionRouterReturn> 
     blah blah blah 
     </wsActionRouterReturn> 
    </wsActionRouterResponse> 
    </soapenv:Body> 
</soapenv:Envelope> 

爲什麼信封不同?

PHP的人特別抱怨p287命名空間,並說他們不能使用結果。我假設他們正在解析響應信封而不考慮名稱空間。

+0

歡迎的軟件標準:)有趣的世界(對不起,如果這句話冒犯了你),但我已經在這個行業很長一段時間,我受夠了這樣的事情,我不知道它背後是無知還是不好。 HTML應該是標準的,不是的,SOAP應該是標準的而不是的,SQL應該是標準的,不是我不知道爲什麼他們甚至會打擾他們的標準。我發現目前爲止最標準化的是JSON。 – 2011-03-02 16:57:20

回答