0

问题:

我有一个带有以下简化 WSDL 的 SOAP 服务:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://new.webservice.namespace" targetNamespace="http://new.webservice.namespace">
    <wsdl:types>
        <xs:schema targetNamespace="http://new.webservice.namespace" elementFormDefault="qualified"/>
    </wsdl:types>
    <wsdl:message name="NewMessageRequest">
        <wsdl:part name="parameter" type="xs:string"/>
    </wsdl:message>
    <wsdl:message name="NewMessageResponse">
        <wsdl:part name="result" type="xs:string"/>
        <wsdl:part name="param2" type="xs:string"/>
    </wsdl:message>
    <wsdl:portType name="NewPortType">
        <wsdl:operation name="NewOperation">
            <wsdl:input message="tns:NewMessageRequest"/>
            <wsdl:output message="tns:NewMessageResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="NewBinding" type="tns:NewPortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="NewOperation">
            <soap:operation soapAction="urn:#NewOperation"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="NewService">
        <wsdl:port name="NewPort" binding="tns:NewBinding">
            <soap:address location="No Target Adress"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

请注意,输出消息有两个部分。

当使用 SoapUI 调用 SOAP 服务时,使用 gSOAP 框架实现的服务返回一个不符合 WSDL 的响应:

这是 SoapUI 请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:new="http://new.webservice.namespace">
   <soapenv:Header/>
   <soapenv:Body>
      <new:NewOperation>
         <parameter>Hello</parameter>
      </new:NewOperation>
   </soapenv:Body>
</soapenv:Envelope>

这是 gSOAP WS 响应:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:new="http://new.webservice.namespace">
   <soapenv:Header/>
   <soapenv:Body>
      <new:NewOperationResponse>
         <result xsi:nil="true"/>
         <param2>Hello World</param2>
      </new:NewOperationResponse>
   </soapenv:Body>
</soapenv:Envelope>

SoapUI 抱怨以下错误:

line5: Element has xsi:nil attribute but is not nillable

问题:

如何修复 WSDL 以使消息部分可以为空?

4

1 回答 1

0

看来你可能已经设置了SOAP_XML_NIL标志?不应设置此标志。请参阅 gsoap 文档说明SOAP_XML_NIL: output NULLs as xsi:nil.

于 2013-11-16T21:03:26.947 回答