Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CXF: Implement multiple ports on same soap:adress?

We got a WSDL from a client, asking us to implement the service on our side.

The WSDL contains 3 port-bindings, with different names and bindings, but identical <soap:adress> --- like this:

<port name="Name1" binding="tns:Binding1">
    <soap:address location="http://localhost/Service/ServicePort" />
</port>
<port name="Name2" binding="tns:Binding2">
    <soap:address location="http://localhost/Service/ServicePort" />
</port>
<port name="Name3" binding="tns:Binding3">
    <soap:address location="http://localhost/Service/ServicePort" />
</port>

Is such WSDL possible to implement with CXF?

When I run wsdl2java, CXF generates 3 java-interfaces.

I first tried a single implementation-class, like

class MyServiceClass implements Interface1, Interface2, Interface3 {...}

But when I deployed it and checked with SoapUI, for some reason, it would only expose Port-binding for Interface1, and seemed to ignore the 2 other ones. Why?

I then tried instead, to implement 3 different ServiceClasses (each implementing one of the interfaces), then put multiple <jaxws:endpoint> with identical address attributes in cxf-config.xml

But I then get deployment-error:

RuntimeException: Soap 1.1 endpoint already registered on address /Address

Any hints, how to implement such WSDL in CXF? Is it possible?

like image 865
Rop Avatar asked Dec 30 '13 18:12

Rop


1 Answers

      But when I deployed it and checked with SoapUI, for some reason, it would only expose Port-binding for Interface1, and seemed to ignore the 2 other ones. Why?

If you will see your implementation class, you will find this annotation,

@WebService(endpointInterface = "yourPackageName.Interface1")

Which is referring to your interface1 only. That's why on deploying it is ignoring rest 2 interface implementations.

So, you have to implement these 3 interface separately in different implemenataion class as you did as per your explanantion. Because only one endpointInterface is allowed in each implementation class.

Is such WSDL possible to implement with CXF?

Yes, it is possible.

During the deployement in your endpoint publisher class, you need to wrap these 3 interface implementation class object in one object and publish for a single end point.

I am still not clear how to do that, ill update the answer later.

Few useful links: It's same requirement but little confusing.

http://cxf.547215.n5.nabble.com/Deploying-multiple-endpoints-ports-for-a-service-td569470.html

Also read about JavaBeans endpoint implementation , i think in this case, it will be more easier than this.

like image 52
kingAm Avatar answered Sep 20 '22 06:09

kingAm