Skip to main content

How can I do a WS using JAX-WS than works in an Axis Client?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
leonardo_josue
Offline
Joined: 2013-06-26

Hi everybody...

I'm trying to do a simple Hello World Web Service using JAX-WS than can be called by an Axis 1.4 client... I'm working with Netbeans 7.3 and a got this.

package mx.org.ws.publicar; 

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

@WebService(serviceName = "HolaMundo")
public class HolaMundo {

@WebMethod(operationName = "hello")
public String hello(@WebParam(name = "name") String txt) {
return "Hello " + txt + " !";
}
}

When I browse the URL for WS (http://localhost:8084/HolaMundo/HolaMundo?wsdl) I got something like this:

<!-- 
Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2-hudson-740-.
-->
<!--
Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2-hudson-740-.
-->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://publicar.ws.org.mx/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://publicar.ws.org.mx/" name="HolaMundo">
<types>
<xsd:schema>
<xsd:import namespace="http://publicar.ws.org.mx/" schemaLocation="http://localhost:8084/HolaMundo/HolaMundo?xsd=1"/>
</xsd:schema>
</types>
<message name="hello">
<part name="parameters" element="tns:hello"/>
</message>
<message name="helloResponse">
<part name="parameters" element="tns:helloResponse"/>
</message>
<portType name="HolaMundo">
<operation name="hello">
<input wsam:Action="http://publicar.ws.org.mx/HolaMundo/helloRequest" message="tns:hello"/>
<output wsam:Action="http://publicar.ws.org.mx/HolaMundo/helloResponse" message="tns:helloResponse"/>
</operation>
</portType>
<binding name="HolaMundoPortBinding" type="tns:HolaMundo">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="hello">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="HolaMundo">
<port name="HolaMundoPort" binding="tns:HolaMundoPortBinding">
<soap:address location="http://localhost:8084/HolaMundo/HolaMundo"/>
</port>
</service>
</definitions>

A few of customers has Axis 1.4 client's to comsume the Web service... like this.

package clientews; 
  
import org.apache.axis.client.Call; 
import org.apache.axis.client.Service; 
  
public class cliente { 
    public cliente() { 
    } 
    
    public static String consumir(Object[] parametros){ 
        String regresar = null; 
        Service service = null;    
        Call call       = null; 
        String endpoint = null; 
        try { 
          endpoint = "http://localhost:8084/HolaMundo/HolaMundo";          
          service = new Service(); 
          call = (Call) service.createCall(); 
          call.setTargetEndpointAddress(new java.net.URL(endpoint)); 
          call.setOperationName("hello");          
          regresar=String.valueOf(call.invoke(parametros));          
        }// try 
        catch (Exception e) { 
          e.printStackTrace(); 
        }// catch 
        finally { 
          return regresar; 
        }// finally 
      } 
  
    public static void main(String[] args) { 
        try {            
            String parametro = "Jos

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
leonardo_josue
Offline
Joined: 2013-06-26

Hi everybody...

I find a possible solution for my problem, but it isn't exactly what I want...

In this page I find another way to invoce the Web Service from Axis 1.4 client:

http://axis.apache.org/axis2/java/core/docs/migration.html

ie instead of doing this:

call.setOperationName("hello");

Must do especify the namespace in the constuctor, like this:

call.setOperationName(new QName("http://localhost:8988/Pruebas/services/HolaMundo", "hello"));

However, this solution means that customers who consume the web service have to modify their code, which is not feasible at all.

The question remains the same, is there any way to modify the Web Service to be called from Axis 1.4 client without having to make any changes?

Best Regards
Leo.