How to generate SOAP 1.2 binding for wsdl using wsdl2java?
Asked Answered
Y

0

10

I brief:

How can i make wsdl2java generate SOAP 1.2 binding?

Detailed description:

I have generated java service classes for wsdl using wsdl2java tool (apache cxf 3.0.2):

MBA-Anton:bin asmirnov$ ./wsdl2java -server -catalog /tmp/wsdl/catalog  -d /tmp/onvif/server http://www.onvif.org/onvif/ver10/network/wsdl/remotediscovery.wsdl

Then i've created service code and run it, it's running:

public static void main(String args[]) throws InterruptedException {
        System.out.println("Starting Server");
        Endpoint.publish("udp://239.255.255.250:3702", new DiscoveryService());

        System.out.println("Server ready...");

        Thread.sleep(10 * 60 * 1000); // 10 min
        System.out.println("Server exiting");
        System.exit(0);
    }

Start log:

Starting Server
28.11.2014 19:51:59 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://www.onvif.org/ver10/network/wsdl}DiscoveryService from class org.onvif.ver10.network.wsdl.DiscoveryLookupPort
28.11.2014 19:52:00 org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be udp://239.255.255.250:3702
28.11.2014 19:52:00 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFO: Creating Service {http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01}Discovery from WSDL: classpath:/org/apache/cxf/ws/discovery/wsdl/wsdd-discovery-1.1-wsdl-os.wsdl
28.11.2014 19:52:00 org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be soap.udp://239.255.255.250:3702
28.11.2014 19:52:00 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01}DiscoveryProxy from class org.apache.cxf.jaxws.support.DummyImpl
Server ready...

Right after start i'm getting in the log:

28.11.2014 19:52:01 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://www.onvif.org/ver10/network/wsdl}DiscoveryService has thrown exception, unwinding now
org.apache.cxf.binding.soap.SoapFault: A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint.
    at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:168)
    at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:65)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    at org.apache.cxf.transport.udp.UDPDestination$MCastListener$2.run(UDPDestination.java:106)
    at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353)
    at java.lang.Thread.run(Thread.java:695)

Then i'm trying to discover the service with ONVIF client (which uses WS-Discovery to find devices) and i'm getting the same error in the log. It makes me feel wsdl2java generated SOAP 1.1 bindings and my webservice can't parse SOAP 1.2 client messages.

How can i make wsdl2java generate SOAP 1.2 binding?

PS. with spring it's doable:

<soap:soapBinding mtomEnabled="true" version="1.2"/>
Yarndyed answered 28/11, 2014 at 14:55 Comment(2)
Hi 4antoine, did you finally succeed to this? and how?Chequer
can I have a look at your wsdl? CXF generates client based on the soap version mentioned in your wsdl, i.e 1.1 or 1.2Candelariacandelario

© 2022 - 2024 — McMap. All rights reserved.