Namespace in argument attribute
-------------------------------
Key: XFIRE-1016
URL: http://jira.codehaus.org/browse/XFIRE-1016
Project: XFire
Issue Type: Bug
Components: JAX-WS
Affects Versions: 1.2.6
Environment: Windows XP, XFire 1.2.6, Java 1.5, NetBeans 5.5.1
Reporter: Ben Brown
Assignee: Dan Diephouse
Attachments: AddService.war
I created the following JAX-WS webservice using NetBeans 5.5.1 (.war attached)
and deployed it on Tomcat:
@WebService()
public class AddWebService {
@WebMethod
public int add(@WebParam(name = "a") final int a, @WebParam(name = "b")
final int b) {
// TODO implement operation
System.out.println("a: " + a + " b: " + b);
return a + b;
}
}
----------------------------------
This generates the following WSDL:
----------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is
JAX-WS RI 2.1.1-b02-RC1. -->
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is
JAX-WS RI 2.1.1-b02-RC1. -->
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://calc.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://calc.org/"
name="AddWebServiceService">
<types>
<xsd:schema>
<xsd:import namespace="http://calc.org/"
schemaLocation="http://localhost:8085/AddService/AddWebService?xsd=1"/>
</xsd:schema>
</types>
<message name="add">
<part name="parameters" element="tns:add"/>
</message>
<message name="addResponse">
<part name="parameters" element="tns:addResponse"/>
</message>
<portType name="AddWebService">
<operation name="add">
<input message="tns:add"/>
<output message="tns:addResponse"/>
</operation>
</portType>
<binding name="AddWebServicePortBinding" type="tns:AddWebService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
<operation name="add">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="AddWebServiceService">
<port name="AddWebServicePort" binding="tns:AddWebServicePortBinding">
<soap:address location="http://localhost:8085/AddService/AddWebService"/>
</port>
</service>
</definitions>
----------------------------------------------------------------------------------------
Navigating to: http://localhost:8085/AddService/AddWebService?xsd=1 gives the
following:
----------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is
JAX-WS RI 2.1.1-b02-RC1. -->
<xs:schema xmlns:tns="http://calc.org/"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"
targetNamespace="http://calc.org/">
<xs:element name="add" type="tns:add"/>
<xs:element name="addResponse" type="tns:addResponse"/>
<xs:complexType name="add">
<xs:sequence>
<xs:element name="a" type="xs:int"/>
<xs:element name="b" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="addResponse">
<xs:sequence>
<xs:element name="return" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
------------------------------------------------------------------------------------------------------------------------------
Created the following XFire client:
Two calls to the web service
1. First way using Client.invoke
2. Second way using generated client stubs from issuing the following command:
org.codehaus.xfire.gen.WsGen -wsdl
http://localhost:8085/AddService/AddWebService?wsdl -o . -p org.calc.client
-overwrite true
------------------------------------------------------------------------------------------------------------------------------
package org.calc.client;
import java.net.URL;
import org.codehaus.xfire.client.Client;
public class AddWebServiceClientTest {
public static void main(String[] args) throws Exception {
Client client;
client = new Client(new
URL("http://localhost:8085/AddService/AddWebService?wsdl"));
Object[] results = client.invoke("add", new Object[] {1, 2});
if (results.length != 0) {
System.out.println("result: " + results[0]);
} else {
System.out.println("NULL RETURN");
}
AddWebServiceServiceClient client2 = new AddWebServiceServiceClient();
AddWebService ws = client2.getAddWebServicePort();
int result = ws.add(3, 5);
System.out.println("result: " + result);
}
}
--------------------------------
I intercepted the SOAP messages:
--------------------------------
<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://calc.org/">
<ns1:a>1</ns1:a>
<ns1:b>2</ns1:b>
</ns1:add>
</soap:Body>
</soap:Envelope>
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:addResponse xmlns:ns2="http://calc.org/">
<return>0</return>
</ns2:addResponse>
</S:Body>
</S:Envelope>
<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://calc.org/">
<ns1:a>3</ns1:a>
<ns1:b>5</ns1:b>
</ns1:add>
</soap:Body>
</soap:Envelope>
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:addResponse xmlns:ns2="http://calc.org/">
<return>0</return>
</ns2:addResponse>
</S:Body>
</S:Envelope>
---------------------------------
The tomcat server log is showing:
---------------------------------
a: 0 b: 0
a: 0 b: 0
Which indicates that the web service is not binding the variable 'a' correctly
---------------------------------------------------
Then I created a web service client using NetBeans:
---------------------------------------------------
public class Main {
public Main() {
}
public static void main(String[] args) {
try {
addserviceclient.AddWebServiceService service = new
addserviceclient.AddWebServiceService();
addserviceclient.AddWebService port =
service.getAddWebServicePort();
int a = 3;
int b = 5;
int result = port.add(a, b);
System.out.println("Result = "+result);
} catch (Exception ex) {
}
}
}
------------------------
SOAP To and From Client:
------------------------
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:add xmlns:ns2="http://calc.org/">
<a>3</a>
<b>5</b>
</ns2:add>
</S:Body>
</S:Envelope>
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:addResponse xmlns:ns2="http://calc.org/">
<return>8</return>
</ns2:addResponse>
</S:Body>
</S:Envelope>
-----------------------------
For some reason, NetBeans client is sending SOAP the NetBeans server can
understand, but when I try to write an XFire client it's not sending the
arguments in a way the NetBeans server can bind the input parameters.
Hope I provided enough information.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email