2014-09-29 102 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);