Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAX-WS SOAP 1.1 / 1.2 Client / Server Generated Code Asymmetry #1

Closed
zebity opened this issue Jan 3, 2023 · 1 comment
Closed

JAX-WS SOAP 1.1 / 1.2 Client / Server Generated Code Asymmetry #1

zebity opened this issue Jan 3, 2023 · 1 comment

Comments

@zebity
Copy link
Owner

zebity commented Jan 3, 2023

Issue:

Testing client and server code generation with JAX-WS SOAP Web Services it seems that the client is generating SOAP 1.2 requests while the server is providing SOAP 1.1 service.

SOAP 1.1 uses HTTP "Content-Type: text/xml"
SOAP 1.2 uses HTTP "Content-Type: application/xml+soap"

Result is that get exception due to having incompatible media types

Need to either change client to use SOAP 1.1 or change server to use provide SOAP 1.2

Environment:

Ubuntu: 22.04
OpenJDK: 11

Maven Dependencies:

JAVA EE/JAKARTA TRANSITIONAL:

  <dependency>
    <groupId>jakarta.xml.bind</groupId>
    <artifactId>jakarta.xml.bind-api</artifactId>
    <version>2.3.3</version>
   </dependency>
   <dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.3.3</version>
    <!-- scope>runtime</scope -->
   </dependency>
   <dependency>
    <groupId>jakarta.xml.ws</groupId>
    <artifactId>jakarta.xml.ws-api</artifactId>
    <version>2.3.3</version>
   </dependency>
   <dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>2.3.3</version>
   </dependency>

<plugin>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>2.3.5</version>
...
</plugin>

NOTE: Same problem using more current Jakarta dependencies

Testing:

via curl and generated Java code.

See here for details: ONVIF Web Services Client Consumption with Java

@zebity
Copy link
Owner Author

zebity commented Jan 11, 2023

Underlying issues is possibly that ONVIF is using a "dead-end" namespace for its binding definition: http://schemas.xmlsoap.org/soap/http

This gets redirected (multiple time) to a link which just contains empty file (mostly nulls).

Resolution was to change the server EndPoint create/public to explicity use SOAP 1.2 / HTTP Binding as per Jakarta specification:

Where String constant: SOAPBinding.SOAP12HTTP_BINDING == http://www.w3.org/2003/05/soap/bindings/HTTP/

EndPoint create/publish code change to create SOAP 1.2 service:

      String soapver = SOAPBinding.SOAP11HTTP_BINDING;
      if (ver.equals("12"))
    	soapver = SOAPBinding.SOAP12HTTP_BINDING;
      
      String uri = "http://127.0.0.1:" + port + request;
      Endpoint ep = Endpoint.create(soapver, device);
      ep.publish(uri);

This works with both Javax and Jakarta namespace, with difference in import statements to reflect JavaEE vs JakartaEE cases.

See commit: f471f3b146021ccf462544a23eb15bbb61fe6441

Also more details on blog page Appendix "D. ONVIF SOAP Binding URL Goes to Dead End"

@zebity zebity closed this as completed Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant