JAX-WS Web Service with XFire Client

I wrote a simple web service and client using XFire. However the server now needs to be JAX-WS. I wrote a simple service using NetBeans but I can't seem to get it to work with XFire. JAX-WS doesn't seem to like the SOAP XFire is sending it and the parameters passed into the web method are nulls instead of the intended values.

Here is my web service:

package org.me.hi;

import javax.jws.WebMethod;

import javax.jws.WebResult;

import javax.jws.WebService;

import javax.jws.soap.SOAPBinding;

import javax.jws.soap.SOAPBinding.Style;

import javax.jws.soap.SOAPBinding.Use;

import javax.jws.soap.SOAPBinding.ParameterStyle;

@WebService(name="HelloWS", targetNamespace="http://hi.me.org")

@SOAPBinding(style=Style.DOCUMENT, use=Use.LITERAL, parameterStyle=ParameterStyle.WRAPPED)

publicclass HelloWS{

@WebMethod(operationName="add", action="")

@WebResult(name="return", targetNamespace="http://hi.me.org")

public Integer add(Integer a, Integer b){

if (a ==null)

{

System.out.println("a is null");

returnnull;

}

if (b ==null)

{

System.out.println("b is null");

returnnull;

}

System.out.println("a: " + a +" b: " + b);

return a + b;

}

}

Here is the WSDL:

<?xml version="1.0" encoding="UTF-8"?>

<definitions xmlns:tns="http://hi.me.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://hi.me.org" name="HelloWSService">

<types>

<xsd:schema>

<xsd:import namespace="http://hi.me.org" schemaLocation="http://localhost:8084/HelloWS/HelloWS?xsd=1"/>

</xsd:schema>

</types>

<message name="add">

<part element="tns:add" name="parameters"/>

</message>

<message name="addResponse">

<part element="tns:addResponse" name="parameters"/>

</message>

<portType name="HelloWS">

<operation name="add">

<input message="tns:add"/>

<output message="tns:addResponse"/>

</operation>

</portType>

<binding type="tns:HelloWS" name="HelloWSPortBinding">

<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

<operation name="add">

<soap:operation soapAction=""/>

<input>

<soap:body use="literal"/>

</input>

<output>

<soap:body use="literal"/>

</output>

</operation>

</binding>

<service name="HelloWSService">

<port binding="tns:HelloWSPortBinding" name="HelloWSPort">

<soap:address location="http://localhost:8084/HelloWS/HelloWS"/>

</port>

</service>

</definitions>

Here is my quick and dirty XFire client:

package org.me.hi;

import java.net.MalformedURLException;

import java.net.URL;

import org.codehaus.xfire.client.Client;

publicclass HelloTest{

publicstaticvoid main(String[] args){

Client client;

try{

client =new Client(new URL("http://localhost:8085/HelloWS/HelloWS?wsdl"));

Object[] results = client.invoke("add",new Object[]{1, 2});

if (results.length != 0){

System.out.println("result: " + (Integer)results[0]);

}else{

System.out.println("null return");

}

}catch (MalformedURLException e){

// TODO Auto-generated catch block

e.printStackTrace();

}catch (Exception e){

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

Here is the SOAP I intercepted between the XFire client and the JAX-WS service:

Calling the web method:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soap:Body>

<ns1:add xmlns:ns1="http://hi.me.org">

<ns1:arg0>1</ns1:arg0>

<ns1:arg1>2</ns1:arg1>

</ns1:add>

</soap:Body>

</soap:Envelope>

Response:

<?xml version="1.0" ?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://hi.me.org">

<soapenv:Body>

<ns1:addResponse></ns1:addResponse>

</soapenv:Body>

</soapenv:Envelope>

Console at the server side:

a isnull

Console at the client side:

nullreturn

Not sure what I'm doing wrong, but I wrote a quick JAX-WS client using NetBeans and it works. We would like to keep using XFire if possible. Here is the SOAP between the JAX-WS client and the JAX-WS web service.

<?xml version="1.0" ?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://hi.me.org/">

<soapenv:Body>

<ns1:add>

<arg0>1</arg0>

<arg1>2</arg1>

</ns1:add>

</soapenv:Body>

</soapenv:Envelope>

<?xml version="1.0" ?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://hi.me.org/">

<soapenv:Body>

<ns1:addResponse>

<return>3</return>

</ns1:addResponse>

</soapenv:Body>

</soapenv:Envelope>

[9453 byte] By [benobia] at [2007-11-27 4:35:43]
# 1

Result after navigating to: http://localhost:8084/HelloWS/HelloWS?xsd=1

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://hi.me.org/" version="1.0">

<xs:element xmlns:ns1="http://hi.me.org/" type="ns1:add" name="add"/>

<xs:complexType name="add">

<xs:sequence>

<xs:element type="xs:int" minOccurs="0" name="arg0"/>

<xs:element type="xs:int" minOccurs="0" name="arg1"/>

</xs:sequence>

</xs:complexType>

<xs:element xmlns:ns2="http://hi.me.org/" type="ns2:addResponse" name="addResponse"/>

<xs:complexType name="addResponse">

<xs:sequence>

<xs:element type="xs:int" minOccurs="0" name="return"/>

</xs:sequence>

</xs:complexType>

</xs:schema>

benobia at 2007-7-12 9:45:49 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Looks like maybe XFire has a bug. Accroding the the schema below, elementFormQualified is not set and the default value is "false" so they should not be sending qualfied names for arg0 and arg1.
dkohlerta at 2007-7-12 9:45:49 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Looks like maybe XFire has a bug. Accroding the the schema that you included, elementFormQualified is not set and the default value is "false" so they should not be sending qualfied names for arg0 and arg1.
dkohlerta at 2007-7-12 9:45:49 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...