开发者

WSDL with soap-rpc-style does not compile

开发者 https://www.devze.com 2023-03-17 06:14 出处:网络
I\'m using this wsdl-file to describe my webservice: <?xml version=\"1.0\" encoding=\"UTF-8\" ?>

I'm using this wsdl-file to describe my webservice:

<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions targetNamespace="http://www.myapproach.开发者_C百科de/knowledgebase" name="Knowledgebase"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="http://www.myapproach.de/knowledgebase"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 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:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy"
    xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
    xmlns:rq="http://www.myapproach.de/knowledgebase">

    <wsdl:types>
    <xsd:schema>
      <xsd:import namespace="http://www.myapproach.de/knowledgebase" schemaLocation="GetValueRequest.xsd"/>
    </xsd:schema>
    </wsdl:types>

    <wsdl:message name="getValueForKey">
        <wsdl:part name="parameters" element="rq:getValueForKey" />
    </wsdl:message>
    <wsdl:message name="getValueForKeyResponse">
        <wsdl:part name="parameters" element="rq:getValueForKeyResponse" />
    </wsdl:message>

    <wsdl:portType name="KnowledgebasePortType">
        <wsdl:operation name="getValueForKey">
            <wsdl:input message="tns:getValueForKey" />
            <wsdl:output message="tns:getValueForKeyResponse" />
        </wsdl:operation>
    </wsdl:portType>

    <wsp:Policy wsu:Id="KnowledgebasePortBinding_WSAM_Addressing_Policy">
        <wsam:Addressing wsp:Optional="true">
            <wsp:Policy />
        </wsam:Addressing>
    </wsp:Policy>

    <wsdl:binding name="KnowledgebasePortBinding" type="tns:KnowledgebasePortType">
        <wsaw:UsingAddressing />
        <wsp:PolicyReference URI="#KnowledgebasePortBinding_WSAM_Addressing_Policy" />
        <!-- http://www.w3.org/2003/05/soap/bindings/HTTP/ -->
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
        <wsdl:operation name="getValueForKey">
            <soap:operation soapAction="http://www.myapproach.de/knowledgebase/getValueForKey" />
            <wsdl:input>
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="Knowledgebase">
        <wsdl:port name="KnowledgebasePortType" binding="tns:KnowledgebasePortBinding">
            <soap:address location="http://www.myapproach.de/knowledgebase" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

GetValueRequest.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.myapproach.de/knowledgebase"  xmlns:tns="http://www.myapproach.de/knowledgebase">

    <xsd:element name="getValueForKey" type="tns:getValueForKey" />
    <xsd:complexType name="getValueForKey">
        <xsd:sequence>
            <xsd:element name="arg0" type="xsd:string" minOccurs="0" />
            <xsd:element name="arg1" type="xsd:string" minOccurs="0" />
            <xsd:element name="arg2" type="xsd:double"></xsd:element>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:element name="getValueForKeyResponse" type="tns:getValueForKeyResponse" />
    <xsd:complexType name="getValueForKeyResponse">
        <xsd:sequence>
            <xsd:element name="return" type="xsd:string" minOccurs="0" />
        </xsd:sequence>
    </xsd:complexType>

</xsd:schema>

Everytime I run wsimport, I get this error:

[wsimport] parsing WSDL...
[wsimport] [ERROR] Invalid wsdl:operation "getValueForKey": its a rpc-literal operation,  message part must refer to a schema type declaration
[wsimport]   line 27 of file:/path/MyFile.wsdl

I have exported the getValueForKey type to the xsd-schemafile, so I don't understand this error... I'm trying this sh*** the whole day grml


Shortly after posting the question I found the answer :-)

Instead of

<wsdl:message name="getValueForKey">
        <wsdl:part name="parameters" element="rq:getValueForKey" />
</wsdl:message>

use this

<wsdl:message name="getValueForKey">
        <wsdl:part name="parameters" type="rq:getValueForKey" />
</wsdl:message>

the attribute "type" must be used instead of "element".

Additionally the soap:body element has to have a namespace

<wsdl:input>
        <soap:body use="literal" namespace="YourNormalNamespace" />
</wsdl:input>


In short, wsdl part has to have type in case of RPC style of webservices else it has to be document style.

0

精彩评论

暂无评论...
验证码 换一张
取 消