0

I am trying to integrate with some legacy application in which they already have defined their message format as well as data structure.

Now we use Java 6 to publish our web service via following code:

Endpoint.publish(urlString, new NotificationListener());

My NotificationListener service contains 1 method and its definition is something as follows:

@WebService
public class NotificationListener {

        @WebMethod(action="notifyStatus111")
         @WebResult(name="NotificationResponse")
      public NotificationResponse notifyStatus1(@WebParam(name="Notification") Notification Notification)
      {
            return new NotificationResponse();
      }

and using wsgen command to generate stubs for the webservice via following ant command:

<project default="wsgen">
 <target name="wsgen" >
  <exec executable="wsgen">
   <arg line="-cp ./bin -keep -s ./src -d ./bin com.xyz.listener.NotificationListener"/>
  </exec>
 </target>
</project>

Now problem is that the generated stubs as well as wsdl creates wrapper with method name over input and output objects.

For example, definition of generated id is as follows:

@XmlRootElement(name = "notifyStatus1")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "notifyStatus1")
public class NotifyStatus1 {

    @XmlElement(name = "notification", namespace = "")
    private com.xyz.listener.notifications.Notification notification;

}

In which notification object is embedded inside the NotifyStatus1 stub.

However legacy application doesn't expect same, instead it expects Notification object to be direct root element.

So is their any way by which I can define Notifcation as root instead of wrapping inside same as wrapper and publish my definition accordingly.

Any points help are highly appreciated.

tarunkumar
  • 861
  • 2
  • 15
  • 30

2 Answers2

0

If you have Notification and NotificationResponse classes already go the other way.

When you have an Endpoint published at http://0.0.0.0:12345/ws with JAX-WS in Java 6 then you can get to the automatically generated WSDL at http://127.0.0.1:12345/ws?wsdl using exactly the classes you have already.

You can then generate a client with wsimport or point the Eclipse Web Service Explorer (in Java EE edition) towards it for testing.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
0

Thanks for your quick feedback time and pointers. I have tried the way you have suggested by not generating stubs classes via wsgen command and published my webservice directly.

Even then the output is same, that I have validated via generated wsdl. Following is the snippet of generated wsdl:

<portType name="NotificationListener">
     <operation name="notifyStatus1">
            <input message="tns:notifyStatus1"/>
             <output message="tns:notifyStatus1Response"/>
      </operation>
</porttype> 
tarunkumar
  • 861
  • 2
  • 15
  • 30