如何从gSoap消息中删除xsi:类型信息? [英] how to remove xsi:type information from gSoap message?

查看:195
本文介绍了如何从gSoap消息中删除xsi:类型信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何从soap消息中删除这些复杂的类型定义


xsi:type =ns4:MYServerRequestDto



xsi:type = ns4:MySettingDto


如何重新生成gsoap文件以使其不包含类型信息? p>

 <?xml version =1.0encoding =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-instancexmlns:xsd =http://www.w3.org/2001/XMLSchemaxmlns:ns5 = http://schemas.datacontract.org/2004/07/System.IOxmlns:ns6 =http://schemas.datacontract.org/2004/07/Systemxmlns:ns3 =http:// schemas。 microsoft.com/2003/10/Serialization/xmlns:ns4 =http://schemas.datacontract.org/2004/07/MYServer.Utilsxmlns: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.xsdxmlns:xenc =http://www.w3.org/2001/04/xmlenc#xmlns:wsc =http://schemas.xmlsoap.org/ws/ 2005/02 / scxmlns: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>


解决方案

如果您使用gSOAP工具生成的代理,您需要使用 SOAP_XML_NOTYPE 标志设置代理的输出模式。



可以通过两种方式完成:


  1. 在代理本身的init函数中的一个位置,但是每次生成代理都会被覆盖。

      void nsTestBindingProxy :: nsTestBindingProxy_init(soap_mode imode,soap_mode omode)
    {
    omode | = SOAP_XML_NOTYPE; // removed 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);



I am woking on windows platform, gSoap is working fine but it integrates complex type defination in the soap message.

How to remove these complex type definition from soap message

xsi:type="ns4:MYServerRequestDto"

xsi:type="ns4:MySettingDto"

how to regenerate gsoap files so it will not include type information?

<?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>

解决方案

If you are using proxy generated by gSOAP tools, then you need to set output mode of the proxy with SOAP_XML_NOTYPE flag.

It can be done in two ways:

  1. In one place in the init function of the proxy itself, but then every time proxy is generated it will be overwritten.

    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. After every initialization of the proxy in code by calling soap_omode function

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

这篇关于如何从gSoap消息中删除xsi:类型信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆