繁体   English   中英

如何在JAXWS中使用相同的wsdl生成多个端口

[英]How to generate multiple ports with same wsdl in JAXWS

我有这个WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
        targetNamespace="http://xmlns.oracle.com/bpmn/bpmnProcess/Process2"
        xmlns:tns="http://xmlns.oracle.com/bpmn/bpmnProcess/Process2"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" >
    <wsdl:types>
        <xsd:schema targetNamespace="http://xmlns.oracle.com/bpmn/bpmnProcess/Process2">
            <xsd:element name="startType">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="argument1" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="endResponseType">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="argument1" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="startRequest">
        <wsdl:part name="parameters" element="tns:startType"/>
    </wsdl:message>
    <wsdl:message name="endResponse">
        <wsdl:part name="parameters" element="tns:endResponseType"/>
    </wsdl:message>
    <wsdl:portType name="Process2PortType">
        <wsdl:operation name="start">
            <wsdl:input message="tns:startRequest" name="startRequest"/>
            <!--<wsdl:output message="tns:endResponse"/>-->
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:portType name="Process2PortTypeCallBack">
        <wsdl:operation name="end">
            <wsdl:input message="tns:endResponse"  name="endResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="process2Soap11" type="tns:Process2PortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="start">
            <soap:operation soapAction="startAction"/>
            <wsdl:input name="startRequest">
                <soap:body use="literal"/>
            </wsdl:input>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="process2CallBack" type="tns:Process2PortTypeCallBack">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="end">
            <soap:operation soapAction="end"/>
            <wsdl:input name="endResponse">
                <soap:body use="literal"/>
            </wsdl:input>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="process">
        <wsdl:port name="processSoap" binding="tns:process2Soap11">
            <soap:address location="http://localhost/sample"/>
        </wsdl:port>
        <wsdl:port name="processSoapCallback" binding="tns:process2CallBack">
            <soap:address location="http://localhost/sampleCallback"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

我正在尝试使用带有JAXWS端点和Spring的Apache CXF创建服务实现,我知道如何在Spring上下文文件中使用类似的方法为每个端口创建一个端点:

<jaxws:endpoint id="personEndpoint1"
                implementor="#process"
                serviceName="hello1"
                endpointName="a"
                address="/process">

    <jaxws:properties>
        <entry key="schema-validation-enabled" value="true"/>
    </jaxws:properties>
</jaxws:endpoint>
<jaxws:endpoint id="personEndpoint2"
                implementor="#processCallback"
                serviceName="hello1"
                endpointName="a"
                address="/process2">

    <jaxws:properties>
        <entry key="schema-validation-enabled" value="true"/>
    </jaxws:properties>
</jaxws:endpoint>

但是,此解决方案创建了两个具有不同WSDL url的端点:

http:// localhost:8080 / process?wsdl

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.springframework.org/schema/beans" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://schemas.xmlsoap.org/soap/http" xmlns:ns1="http://xmlns.oracle.com/bpmn/bpmnProcess/Process2" name="hello1" targetNamespace="http://www.springframework.org/schema/beans">
    <wsdl:import location="http://localhost:8080/process?wsdl=Process2PortType.wsdl" namespace="http://xmlns.oracle.com/bpmn/bpmnProcess/Process2"/>
    <wsdl:binding name="hello1SoapBinding" type="ns1:Process2PortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="start">
            <soap:operation soapAction="startAction" style="document"/>
            <wsdl:input name="start">
                <soap:body use="literal"/>
            </wsdl:input>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="hello1">
        <wsdl:port binding="tns:hello1SoapBinding" name="a">
            <soap:address location="http://localhost:8080/process"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

http:// localhost:8080 / process2?wsdl

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.springframework.org/schema/beans" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://schemas.xmlsoap.org/soap/http" xmlns:ns1="http://xmlns.oracle.com/bpmn/bpmnProcess/Process2" name="hello1" targetNamespace="http://www.springframework.org/schema/beans">
    <wsdl:import location="http://localhost:8080/process2?wsdl=Process2PortTypeCallBack.wsdl" namespace="http://xmlns.oracle.com/bpmn/bpmnProcess/Process2"/>
    <wsdl:binding name="hello1SoapBinding" type="ns1:Process2PortTypeCallBack">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="end">
            <soap:operation soapAction="end" style="document"/>
            <wsdl:input name="end">
                <soap:body use="literal"/>
            </wsdl:input>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="hello1">
        <wsdl:port binding="tns:hello1SoapBinding" name="a">
            <soap:address location="http://localhost:8080/process2"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

这不是我所需要的,我需要使用相同的WSDL地址来使用两个端口,就像在原始WSDL中一样。 如何使用JAXWS和Spring配置实现这一目标?

这可能已经老了,但是对于路过的人而言; 我有完全一样的情况。 只需让服务标签中的端口定义指向同一位置即可。 即:

<soap:address location="http://localhost/sample"/>

<soap:address location="http://localhost/sampleCallback"/>

在原始WSDL中指向同一位置,这将检索原始WSDL。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM