Skip to main content

How to customize the JAXWS mapping of an SOAP operation whose name is reserved in Java

1 reply [Last post]
cyril4j
Offline
Joined: 2011-03-24
Points: 0

I'm trying to compile a wsdl from a partner with JAX-WS 2.2.6 embedded in GlassFish 3.1.2.2 and get the following compilation error:

 [wsimport] [ERROR] Invalid operation "Void", it's java reserved word, can't generate java method. Use customization to change the operation name.

So I tried to map this operation name to another Java method name via a custom JAXWS binding file:

<?xml version="1.0" encoding="utf-8"?>
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
                xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                wsdlLocation="https://partner.com/BasicOperationsService?wsdl">

  <jaxws:bindings node="wsdl:definitions/wsdl:binding[@name='BasicHttpBinding_BasicOperations']/wsdl:operation[@name='Void']">
    <jaxws:method name="voidTx"/>
  </jaxws:bindings->

</jaxws:bindings>

but it doesn't seem to recognize this method element:

 [wsimport] [ERROR] invalid extension element: "jaxws:method" (in namespace "http://java.sun.com/xml/ns/jaxws")

I'm a bit at loss as this is the correct namespace and is exactly as documented in section 9.2.7.1 of https://jax-ws.java.net/nonav/2.2.6/docs/ch03.html#standard-customizations

It's not an xpath issue as if I alter the node, then I get another error that the "XPath evaluation results in an empty target node".

Any idea? Thanks!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
scchen
Offline
Joined: 2010-03-11
Points: 0

Instead of customize the binding/operation, try change the customization target node to be the portType operation as the following example:
9.2.7.1. Service Endpoint Interface Methods

wsimport will generate a method named add instead of the default addNumbers in this example:

<!-- wsdl:portType operation customization -->
<bindings       node="wsdl:definitions/wsdl:portType[@name='AddNumbersImpl']/wsdl:operation[@name='addNumbers']">
    <!-- change java method name from addNumbers() to add() -->
    <method name="add">
        <javadoc>Adds the numbers</javadoc>
    </method>
</bindings>

https://jax-ws.java.net/nonav/2.2.6/docs/ch03.html#standard-customizations