生成xsd并根据JAX-WS中的要求设置字段

时间:2016-08-04 04:05:40

标签: wsdl jax-ws

Request description

以下是上图中概述的规范的实现。

@WebService
@SOAPBinding(style = Style.DOCUMENT)
public interface WithdrawService {

    @WebMethod
    public Response withdraw(
            @WebParam(name="CORPCODE") String corpcode,
            @WebParam(name="SERVCODE") String servcode, 
            @WebParam(name="AMOUNT") double amount, 
            @WebParam(name="CCYID") String ccyid, 
            @WebParam(name="ACCTNO") String acctno, 
            @WebParam(name="REFVAL1") String refvel1, 
            @WebParam(name="REFVAL2") String refval2, 
            @WebParam(name="TRANREF") String tranref, 
            @WebParam(name="DESC") String desc, 
            @WebParam(name="LICENSEID") String licenseid, 
            @WebParam(name="LICENSEKEY") String licensekey
            );

}

当用户访问?wsdl链接时,会生成以下WSDL。

<!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b. 
-->
<!-- Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b. 
-->
<definitions targetNamespace="http://withdraw.kbz.nirvasoft.com/" name="WithdrawServiceImplService">
    <types>
        <xsd:schema>
            <xsd:import namespace="http://withdraw.kbz.nirvasoft.com/" schemaLocation="http://localhost:8080/WithdrawService/withdraw?xsd=1"/>
        </xsd:schema>
    </types>
    <message name="withdraw">
        <part name="parameters" element="tns:withdraw"/>
    </message>
    <message name="withdrawResponse">
        <part name="parameters" element="tns:withdrawResponse"/>
    </message>
    <portType name="WithdrawService">
        <operation name="withdraw">
            <input wsam:Action="http://withdraw.kbz.nirvasoft.com/WithdrawService/withdrawRequest" message="tns:withdraw"/>
            <output wsam:Action="http://withdraw.kbz.nirvasoft.com/WithdrawService/withdrawResponse" message="tns:withdrawResponse"/>
        </operation>
    </portType>
    <binding name="WithdrawServiceImplPortBinding" type="tns:WithdrawService">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <operation name="withdraw">
            <soap:operation soapAction=""/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
    </binding>
    <service name="WithdrawServiceImplService">
        <port name="WithdrawServiceImplPort" binding="tns:WithdrawServiceImplPortBinding">
            <soap:address location="http://localhost:8080/WithdrawService/withdraw"/>
        </port>
    </service>
</definitions>

我们对两件事感到不满。

  1. 我们没有获得所用类型的任何xsd文档。
  2. 我们无法确定生成的wsdl中是否需要字段。
  3. 我想知道如何使用我们的代码实现它们。

1 个答案:

答案 0 :(得分:0)

您可以从中获取XSD http://localhost:8080/WithdrawService/withdraw?xsd=1

根据您使用的服务器,您可以要求JAX-WS生成嵌入式XSD文件。或者,您可以要求JAX-WS使用您自己的WSDL。