CXF: Implement multiple ports on same soap:adress?
Asked Answered
P

1

8

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?

Politician answered 30/12, 2013 at 18:51 Comment(1)
cxf.547215.n5.nabble.com/… seems related (but not helpful).Anglaangle
L
3
      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.

Lecher answered 1/1, 2014 at 10:4 Comment(3)
Thanks for input! Looking fwd to your update :) --- not easy to google up the details on this...Politician
Actually , i have prepared a scenario in my system for this requirement, still searching for classes, libraries etc in oracle doc to achieve this. nice catch btw.Lecher
I did find a hint here: cxf.547215.n5.nabble.com/… (comment by Daniel Kulp halfway down the page). I added the property "allow-multiplex-endpoint" to cxf-servlet.xml, which actually eliminated the url/port-conflict error. But behaviour still not correct, only one of the interfaces get exposed. The additional steps to implement and configure AbstractEndpointSelectionInterceptor, I was not able to figure out from the code-example he links to.Politician

© 2022 - 2024 — McMap. All rights reserved.