You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Howard Gao <ho...@iona.com> on 2006/11/15 04:32:17 UTC
cxf gen client got Nullpointer
Hi guys,
This probably a real issue.
I started with a simple interface, as below:
package com.cxf;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.soap.SOAPBinding;
@WebService(name="Hello", targetNamespace="http://cxf.com/")
public interface Hello {
@SOAPBinding(parameterStyle=javax.jws.soap.SOAPBinding.ParameterStyle.BARE,
style=javax.jws.soap.SOAPBinding.Style.RPC,
use=javax.jws.soap.SOAPBinding.Use.LITERAL)
@WebMethod(operationName="sayHi", exclude=false)
String sayHi();
}
Then I use java2wsdl to generate the following wsdl
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://cxf.com/"
xmlns:tns="http://cxf.com/" xmlns:ns1="http://cxf.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema targetNamespace="http://cxf.com/" version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="sayHiResponse" nillable="true" type="xs:string"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="sayHi">
</wsdl:message>
<wsdl:message name="sayHiResponse">
<wsdl:part name="return" type="xsd:string">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="Hello">
<wsdl:operation name="sayHi">
<wsdl:input name="sayHi" message="tns:sayHi">
</wsdl:input>
<wsdl:output name="sayHiResponse" message="tns:sayHiResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloBinding" type="tns:Hello">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sayHi">
<soap:operation style="rpc"/>
<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="HelloService">
<wsdl:port name="HelloPort" binding="tns:HelloBinding">
<soap:address location="http://localhost:9000/Hello"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Using that wsdl, I use wsdl2java to generate the simple Server and
Client. I start up the server and then the client. From the client site
I got a NullPointerException, stack trace:
INFO: Creating Service {http://cxf.com/}HelloService from WSDL.
Exception in thread "main" java.lang.NullPointerException
at
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeParameter(JaxWsServiceFactoryBean.java:260)
at
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeParameter(JaxWsServiceFactoryBean.java:242)
at
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeClassInfo(JaxWsServiceFactoryBean.java:222)
at
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeWSDLOperation(JaxWsServiceFactoryBean.java:122)
at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperations(ReflectionServiceFactoryBean.java:239)
at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:178)
at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:116)
at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:239)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:199)
at javax.xml.ws.Service.getPort(Service.java:94)
at com.cxf.HelloService.getHelloPort(HelloService.java:67)
at com.cxf.HelloClient.main(HelloClient.java:65)
--
Howard Gao
Re: cxf gen client got Nullpointer
Posted by James Mao <ja...@iona.com>.
Hi,
The wsdl generated from the SEI is correct.
It seems that the RT is looking for {http://cxf.com}out instead of
{http://cxf.com}return, that cause the problem.
The solution i can give is a workaround solution, you can add the
WebResult annotation for the method.
I'll looking into the RT later.
Thanks,
James.
> Hi guys,
>
> This probably a real issue.
>
> I started with a simple interface, as below:
>
> package com.cxf;
> import javax.jws.WebService;
> import javax.jws.WebMethod;
> import javax.jws.soap.SOAPBinding;
>
> @WebService(name="Hello", targetNamespace="http://cxf.com/")
> public interface Hello {
>
>
> @SOAPBinding(parameterStyle=javax.jws.soap.SOAPBinding.ParameterStyle.BARE,
> style=javax.jws.soap.SOAPBinding.Style.RPC,
> use=javax.jws.soap.SOAPBinding.Use.LITERAL)
> @WebMethod(operationName="sayHi", exclude=false)
> String sayHi();
> }
>
> Then I use java2wsdl to generate the following wsdl
>
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions targetNamespace="http://cxf.com/"
> xmlns:tns="http://cxf.com/" xmlns:ns1="http://cxf.com/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
> <wsdl:types>
> <xsd:schema targetNamespace="http://cxf.com/" version="1.0"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <xs:element name="sayHiResponse" nillable="true" type="xs:string"/>
> </xsd:schema>
> </wsdl:types>
> <wsdl:message name="sayHi">
> </wsdl:message>
> <wsdl:message name="sayHiResponse">
> <wsdl:part name="return" type="xsd:string">
> </wsdl:part>
> </wsdl:message>
> <wsdl:portType name="Hello">
> <wsdl:operation name="sayHi">
> <wsdl:input name="sayHi" message="tns:sayHi">
> </wsdl:input>
> <wsdl:output name="sayHiResponse" message="tns:sayHiResponse">
> </wsdl:output>
> </wsdl:operation>
> </wsdl:portType>
> <wsdl:binding name="HelloBinding" type="tns:Hello">
> <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
> <wsdl:operation name="sayHi">
> <soap:operation style="rpc"/>
> <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="HelloService">
> <wsdl:port name="HelloPort" binding="tns:HelloBinding">
> <soap:address location="http://localhost:9000/Hello"/>
> </wsdl:port>
> </wsdl:service>
> </wsdl:definitions>
>
> Using that wsdl, I use wsdl2java to generate the simple Server and
> Client. I start up the server and then the client. From the client
> site I got a NullPointerException, stack trace:
>
> INFO: Creating Service {http://cxf.com/}HelloService from WSDL.
> Exception in thread "main" java.lang.NullPointerException
> at
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeParameter(JaxWsServiceFactoryBean.java:260)
>
> at
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeParameter(JaxWsServiceFactoryBean.java:242)
>
> at
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeClassInfo(JaxWsServiceFactoryBean.java:222)
>
> at
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeWSDLOperation(JaxWsServiceFactoryBean.java:122)
>
> at
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperations(ReflectionServiceFactoryBean.java:239)
>
> at
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:178)
>
> at
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:116)
>
> at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:239)
> at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:199)
> at javax.xml.ws.Service.getPort(Service.java:94)
> at com.cxf.HelloService.getHelloPort(HelloService.java:67)
> at com.cxf.HelloClient.main(HelloClient.java:65)
>
>
>
>