2014-09-29 94 views
2

我在Windows平臺上工作,gSoap工作正常,但它集成了soap消息中的複雜類型定義。如何從gSoap消息中刪除xsi:type信息?

如何刪除從SOAP消息這些複雜類型定義

的xsi:type = 「NS4:MYServerRequestDto」

的xsi:type = 「NS4:MySettingDto」

如何重新生成gsoap文件,以便它不包含類型信息?

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns5="http://schemas.datacontract.org/2004/07/System.IO" xmlns:ns6="http://schemas.datacontract.org/2004/07/System" xmlns:ns3="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns4="http://schemas.datacontract.org/2004/07/MYServer.Utils" xmlns:ns1="http://tempuri.org/" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
    <SOAP-ENV:Body> 
    <ns1:Register> 
     <ns1:request xsi:type="ns4:MYServerRequestDto"> 
     <ns4:SerialNumber>2</ns4:SerialNumber> 
     <ns4:MySetting xsi:type="ns4:MySettingDto"> 
      <ns4:AVersion>2</ns4:AVersion> 
      <ns4:BVersion>2</ns4:BVersion> 
     </ns4:MYSetting> 
     <ns4:IPAddress>192.168.1.199</ns4:IPAddress> 
     </ns1:request> 
    </ns1:Register> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

回答

3

如果您使用的是由gSOAP的工具生成的代理,那麼你需要設置代理的輸出模式SOAP_XML_NOTYPE標誌。

它可以通過兩種方式來完成:

  1. 在一個地方的代理本身的初始化函數,但隨後每當產生的代理將被覆蓋。

    void nsTestBindingProxy::nsTestBindingProxy_init(soap_mode imode, soap_mode omode) 
    { 
        omode |= SOAP_XML_NOTYPE; //removes xsi:type 
        soap_imode(this->soap, imode); 
        soap_omode(this->soap, omode); 
        soap_endpoint = NULL; 
        ... 
    } 
    
  2. 在代碼中代理的每一個初始化後通過調用函數soap_omode

    nsTestBindingProxy proxy(); 
    soap_omode(proxy.soap, proxy.soap->omode | SOAP_XML_NOTYPE);