簡體   English   中英

無法從WSDL創建JAX-WS服務

[英]Unable to create JAX-WS service from WSDL

我有一個WSDL文檔:

<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:tns="http://java.CAEServer"
             xmlns:server="http://caeserver.caebeans.org"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns="http://schemas.xmlsoap.org/wsdl/"
             targetNamespace="http://java.CAEServer"
             name="CAEInstanceImplService">

    <types>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                    targetNamespace="http://caeserver.caebeans.org"
                    xmlns:test="http://example.org"
                    xmlns:wsa="http://www.w3.org/2005/08/addressing"
                    xmlns:serv="http://caeserver.caebeans.org"
                    attributeFormDefault="unqualified" elementFormDefault="qualified">

            <xsd:element name="data" type="xsd:string"/>

            <xsd:element name="parameter">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="text">
                            <xsd:complexType>
                                <xsd:attribute name="data" type="xsd:string"/>
                            </xsd:complexType>
                        </xsd:element>
                        <xsd:element name="units">
                            <xsd:complexType>
                                <xsd:attribute name="data" type="xsd:string"/>
                            </xsd:complexType>
                        </xsd:element>
                        <xsd:element name="comment">
                            <xsd:complexType>
                                <xsd:attribute name="data" type="xsd:string"/>
                            </xsd:complexType>
                        </xsd:element>
                        <xsd:element name="enums" type="xsd:string"/>
                        <xsd:element name="default" type="xsd:int"/>
                        <xsd:element name="value" type="xsd:string"/>
                    </xsd:sequence>
                    <xsd:attribute name="name" type="xsd:string"/>
                    <xsd:attribute name="type" type="xsd:string"/>
                    <xsd:attribute name="visible" type="xsd:boolean"/>
                </xsd:complexType>
            </xsd:element>

            <xsd:complexType name="languageData">
                <xsd:simpleContent>
                    <xsd:extension base="xsd:string">
                        <xsd:attribute name="name" type="xsd:string"/>
                    </xsd:extension>
                </xsd:simpleContent>
            </xsd:complexType>

            <xsd:element name="language">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element maxOccurs="unbounded" name="data" type="serv:languageData"/>
                    </xsd:sequence>
                    <!--<xsd:attribute name="xml:lang" type="xsd:string"/>-->
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="instance_ID" type="xsd:string"/>

            <xsd:element name="problemCaebean">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="categories">
                            <xsd:complexType>
                                <xsd:sequence>
                                    <xsd:element name="category">
                                        <xsd:complexType>
                                            <xsd:sequence>
                                                <xsd:element maxOccurs="unbounded" ref="serv:parameter"/>
                                            </xsd:sequence>
                                            <xsd:attribute name="name" type="xsd:string"/>
                                            <xsd:attribute name="data" type="xsd:string"/>
                                        </xsd:complexType>
                                    </xsd:element>
                                </xsd:sequence>
                            </xsd:complexType>
                        </xsd:element>
                        <xsd:element name="resources">
                            <xsd:complexType>
                                <xsd:sequence>
                                    <xsd:element maxOccurs="unbounded" ref="serv:language"/>
                                </xsd:sequence>
                            </xsd:complexType>
                        </xsd:element>
                    </xsd:sequence>
                    <xsd:attribute name="name" type="xsd:string"/>
                    <xsd:attribute name="author" type="xsd:string"/>
                    <xsd:attribute name="version" type="xsd:decimal"/>
                    <xsd:attribute name="caebeanId" type="xsd:string"/>
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="caeProject">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element ref="serv:problemCaebean"/>
                        <xsd:element name="logical">
                            <xsd:complexType>
                                <xsd:sequence>
                                    <xsd:element maxOccurs="unbounded" name="node">
                                        <xsd:complexType>
                                            <xsd:attribute name="id" type="xsd:string"/>
                                            <xsd:attribute name="type" type="xsd:string"/>
                                            <xsd:attribute name="condition" type="xsd:string"/>
                                            <xsd:attribute name="execute" type="xsd:string"/>
                                            <xsd:attribute name="x" type="xsd:int"/>
                                            <xsd:attribute name="y" type="xsd:int"/>
                                        </xsd:complexType>
                                    </xsd:element>
                                    <xsd:element maxOccurs="unbounded" name="edge">
                                        <xsd:complexType>
                                            <xsd:attribute name="source" type="xsd:string"/>
                                            <xsd:attribute name="target" type="xsd:string"/>
                                            <xsd:attribute name="when" type="xsd:boolean"/>
                                        </xsd:complexType>
                                    </xsd:element>
                                </xsd:sequence>
                            </xsd:complexType>
                        </xsd:element>
                        <xsd:element name="physical">
                            <xsd:complexType>
                                <xsd:sequence>
                                    <xsd:element name="componentCaebean">
                                        <xsd:complexType>
                                            <xsd:sequence>
                                                <xsd:element maxOccurs="unbounded" name="input">
                                                    <xsd:complexType>
                                                        <xsd:attribute name="filename" type="xsd:string"/>
                                                    </xsd:complexType>
                                                </xsd:element>
                                                <xsd:element maxOccurs="unbounded" name="output">
                                                    <xsd:complexType>
                                                        <xsd:attribute name="filename" type="xsd:string"/>
                                                    </xsd:complexType>
                                                </xsd:element>
                                                <xsd:element name="jar-premode">
                                                    <xsd:complexType>
                                                        <xsd:attribute name="name" type="xsd:string"/>
                                                    </xsd:complexType>
                                                </xsd:element>
                                                <xsd:element name="exec">
                                                    <xsd:complexType>
                                                        <xsd:sequence>
                                                            <xsd:element name="param">
                                                                <xsd:complexType>
                                                                    <xsd:attribute name="name" type="xsd:string"/>
                                                                </xsd:complexType>
                                                            </xsd:element>
                                                        </xsd:sequence>
                                                        <xsd:attribute name="name" type="xsd:string"/>
                                                        <xsd:attribute name="appname" type="xsd:string"/>
                                                        <xsd:attribute name="appversion" type="xsd:decimal"/>
                                                    </xsd:complexType>
                                                </xsd:element>
                                            </xsd:sequence>
                                            <xsd:attribute name="name" type="xsd:string"/>
                                        </xsd:complexType>
                                    </xsd:element>
                                </xsd:sequence>
                            </xsd:complexType>
                        </xsd:element>
                    </xsd:sequence>
                    <xsd:attribute name="name" type="xsd:string"/>
                    <xsd:attribute name="author" type="xsd:string"/>
                    <xsd:attribute name="version" type="xsd:decimal"/>
                    <xsd:attribute name="id" type="xsd:string"/>
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="Status">
                <xsd:complexType>
                    <xsd:choice>
                        <xsd:element name="NOT_STARTED"/>
                        <xsd:element name="RUNNING"/>
                        <xsd:element name="HELD"/>
                        <xsd:element name="SUCCESSFULL"/>
                        <xsd:element name="FAILED"/>
                    </xsd:choice>
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="CurrentTime">
                <xsd:complexType>
                    <xsd:simpleContent>
                        <xsd:extension base="xsd:dateTime">
                            <xsd:anyAttribute namespace="##other" processContents="lax"/>
                        </xsd:extension>
                    </xsd:simpleContent>
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="TerminationTime" nillable="true">
                <xsd:complexType>
                    <xsd:simpleContent>
                        <xsd:extension base="xsd:dateTime">
                            <xsd:anyAttribute namespace="##other" processContents="lax"/>
                        </xsd:extension>
                    </xsd:simpleContent>
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="Description">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element ref="serv:Status"/>
                        <xsd:element ref="serv:TerminationTime"/>
                        <xsd:element ref="serv:CurrentTime"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>

            <!--
            message used to create a new instance WS-Resource
            -->
            <xsd:element name="createInstance">
                <xsd:complexType/>
            </xsd:element>

            <!--
               the response, simply contains an EPR to the new instance
            -->
            <xsd:element name="createInstanceResponse">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="instanceID" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="submitJob">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element ref="serv:instance_ID"/>
                        <xsd:element ref="serv:problemCaebean"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="submitJobResponse">
                <xsd:complexType>
                    <xsd:sequence>
                        <!--<xsd:element name="xml" type="xsd:string"/>-->
                        <xsd:element name="Result" type="xsd:int"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="getStatus">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="instance_ID" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="getStatusResponse">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element ref="serv:Status"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>

        </xsd:schema>
    </types>

    <message name="SubmitJobRequest">
        <part name="parameter" element="server:submitJob"/>
    </message>

    <message name="SubmitJobResponse">
        <part name="parameter" element="server:submitJobResponse"/>
    </message>

    <message name="GetStatusRequest">
        <part name="parameter" element="server:getStatus"/>
    </message>

    <message name="GetStatusResponse">
        <part name="parameter" element="server:getStatusResponse"/>
    </message>

    <portType name="CAEInstance">
        <operation name="SubmitJob">
            <input message="tns:SubmitJobRequest"/>
            <output message="tns:SubmitJobResponse"/>
        </operation>
        <operation name="GetStatus">
            <input message="tns:GetStatusRequest"/>
            <output message="tns:GetStatusResponse"/>
        </operation>
    </portType>

    <binding name="CAEInstanceImplPortBinding" type="tns:CAEInstance">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <operation name="SubmitJob">
            <soap:operation soapAction="http://java.CAEServer/submitJob"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
        <operation name="GetStatus">
            <soap:operation soapAction="http://java.CAEServer/getStatus"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
    </binding>

    <service name="CAEInstanceImplService">
        <port name="CAEInstanceImplPort" binding="tns:CAEInstanceImplPortBinding">
            <soap:address location="http://127.0.0.1:9000/caeinstance"/>
        </port>
    </service>
</definitions>

我正在使用命令創建類型和服務定義

wsimport -keep -verbose ../src/main/resources/instance.wsdl

但是當我編譯並運行我的項目並嘗試從生成的WSDL編譯客戶端存根時,出現了一個錯誤

parsing WSDL...


[ERROR] undefined element declaration 'ns1:instance_ID'
  line 36 of http://localhost:9000/caeinstance?xsd=1

[ERROR] undefined element declaration 'ns1:Result'
  line 49 of http://localhost:9000/caeinstance?xsd=1

我的WSDL有什么問題?

CXF和Eclipse都提供WSDL驗證器。 您應該通過其中之一來運行WSDL,並查看其內容。

您是否創建了該WSDL? 我認為您正在嘗試使用某些未在WSDL中導出的數據類型。

wsdl引用了一個名為“ s”的模式,但是找不到,因為它的URL是XMLSchema,但是應該是XMLSchema.xsd

您可以使用wsimport -b http://www.w3.org/2001/XMLSchema.xsd usrtowsdl?WSDL

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM