简体   繁体   中英

How to generate multiple ports with same wsdl in JAXWS

I have this 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>

I am trying to create a service implementation using Apache CXF with JAXWS endpoints and Spring, I know how to create an endpoint for each port, using something like this in the Spring context file:

<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>

However, this solution creates two endpoints with different WSDL urls:

. 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>

and

. 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>

This is not what I need, I need that the two ports are available using the same WSDL address, as in the original WSDL. How can I achieve this using JAXWS and Spring configuration?

This might be aged but for someone passingby; I have exact same situation. Simply let the port definitions in the service tag point to the same location. ie:

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

and

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

in the original WSDL point at the same location and that will retrieve the original WSDL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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