I found a workaround to the return value null problem. Here's the
additional info: I have an annotated interface for the service in the
server, and am generating the WSDL using java2wsdl. Then I generate the
client using this wsdl using wsdl2java. I was getting the null until I
changed the SOAPBinding.parameterStyle to BARE. The default value of
WRAPPED causes it to fail. So now my interface looks like this:
@WebService
public interface HelloWorld {
@WebMethod
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
String sayHi(String text);
}
I wonder if it has anything to do with the default name of the WebResult
is 'return'. In the implementation, I think this gets renamed to
'_return'. Maybe this is why the return value doesn't get unmarshalled
correctly, not sure....
-----Original Message-----
From: Marty Saxton [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 18, 2007 12:45 PM
To: [email protected]
Subject: RE: attempting HelloWorld service, getting NULL return value
Yes, something is up with the client, and it's only in jax-ws frontend.
The simple front end works. I am using CXF 2.0-incubator.
Here's my main. The 1st hunk of code uses the classes generated from
the java2wsdl tool. This is the one that is returning the null. The
2nd hunk of code uses the simple front end, and it works fine.
public static void main(String[] args) {
HelloWorldImplService hws = new HelloWorldImplService();
HelloWorld hw = hws.getHelloWorldImplPort();
String s = hw.sayHi("asdf");
System.out.println(s);
final String SERVICE_URL =
"http://localhost:8080/hello/HelloWorld";
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setServiceClass(HelloWorld.class);
factory.setAddress(SERVICE_URL);
HelloWorld helloWorldClient = (HelloWorld) factory.create();
s = helloWorldClient.sayHi("asdf");
System.out.println(s);
}
Here's the HelloWorld interface that was generated by java2wsdl (run
from the maven plugin). The one thing that is suspect is the
targetNamespace for @WebResult is empty string. I think it should be
"http://test.twowire/".
@WebService(targetNamespace = "http://test.twowire/", name =
"HelloWorld")
public interface HelloWorld {
@WebResult(targetNamespace = "", name = "return")
@RequestWrapper(localName = "sayHi", targetNamespace =
"http://test.twowire/", className = "twowire.test.SayHi")
@ResponseWrapper(localName = "sayHiResponse", targetNamespace =
"http://test.twowire/", className = "twowire.test.SayHiResponse")
@WebMethod
public java.lang.String sayHi(
@WebParam(targetNamespace = "", name = "arg0")
java.lang.String arg0
);
}
Here is the WSDL (which was generated via wsdl2java):
<?xml version="1.0" encoding="UTF-8" standalone="no"?><wsdl:definitions
xmlns:ns1="http://test.twowire/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="HelloWorldImplService" targetNamespace="http://test.twowire/">
<wsdl:types>
<xsd:schema xmlns="http://test.twowire/"
attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="http://test.twowire/">
<xsd:element name="sayHi" type="sayHi"/>
<xsd:complexType name="sayHi">
<xsd:sequence>
<xsd:element minOccurs="0" name="arg0" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="sayHiResponse" type="sayHiResponse"/>
<xsd:complexType name="sayHiResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="return" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="sayHiResponse">
<wsdl:part element="ns1:sayHiResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="sayHi">
<wsdl:part element="ns1:sayHi" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="HelloWorld">
<wsdl:operation name="sayHi">
<wsdl:input message="ns1:sayHi" name="sayHi">
</wsdl:input>
<wsdl:output message="ns1:sayHiResponse" name="sayHiResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloWorldImplServiceSoapBinding"
type="ns1:HelloWorld">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sayHi">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="sayHi">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="sayHiResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWorldImplService">
<wsdl:port binding="ns1:HelloWorldImplServiceSoapBinding"
name="HelloWorldImplPort">
<soap:address location="http://localhost:8080/hello/HelloWorld"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Thanks in advance!
-----Original Message-----
From: Liu, Jervis [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 17, 2007 9:09 PM
To: [email protected]
Subject: RE: attempting HelloWorld service, getting NULL return value
Hi Marty, as you said, you've examined the message flowing between
client and client and it is correct, in this case, must be sth wrong
with your client. You may want to send us your client code, so that we
can take a quick look to see what happened there.
Thanks,
Jervis
-----Original Message-----
From: Marty Saxton [mailto:[EMAIL PROTECTED]
Sent: 2007?7?18? 3:35
To: [email protected]
Subject: attempting HelloWorld service, getting NULL return value
I am using CXF as both the client and server, and I'm just trying to get
the following simple service working:
@WebService
public interface HelloWorld {
String sayHi(String text);
}
The implementation just returns "Hello " + text. I examined the XML
flowing between the client & server and it appears correct, the server
is returning a correct message. On the client side, using the jax-ws
frontend, I get a null instead of a string for the return value. I must
be doing something terribly wrong, but I'm not sure where to begin
debugging this problem.
Thanks in advance!
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
Ireland