cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Freeman Fang <freeman.f...@gmail.com>
Subject Re: Web Service Method Returns null
Date Sun, 09 Jan 2011 12:03:56 GMT
Hi,

My comment inline
On 2011-1-9, at 上午12:01, Michael wrote:

> Recently I've posted several issues I've been having using Eclipse  
> Helios (3.6), CXF runtime (2.3.0), Tomcat (6.0) and Java  
> (1.6.0_22).  As is often the case the cause of the problem was user  
> error and quite simple to remedy.
>
> Simply, my WSDL soap:address was pointing to my deployed WSDL  
> location not my service location.  The was the cause of the content  
> type error I was getting in my client.
>
> I found a good description of the CXF Servlet functionality and the  
> cxf-servlet.xml and was able to provide the correct soap:address in  
> my WSDL.
>
> The only problem I have remaining is my web service is returning a  
> null value when it should be returning a string saying hello from  
> the web service.  I'm posting some code and my WSDL below.
>
> Can someone take a look at this and see if you can tell me what I  
> might be doing wrong?  If you need more information just let me know  
> what to post.
>
> package org.self;
>
> import javax.jws.WebService;
>
> @WebService(targetNamespace = "http://self.org/",
>            portName = "HelloWorldWebServicePort",
>            serviceName = "HelloWorldWebServiceService")
> public class HelloWorldWebService
> {
> public String SayHello( )
> {
>  return "Hello World  From HelloWorldWebService On Tomcat";
// when you call  hwwsPortType.sayHello( ), this method not get invoked.
>
> }
> }
>
There should be a class implements HelloWorldWebServicePortType  
interface have sayHello method and return whatever you want to return,  
but not the one in HelloWorldWebService.

Freeman
> package org.self;
>
> public final class Client
> {
>    public static void main(String args[])
>    {
>        HelloWorldWebService hwws = new HelloWorldWebService( );
>        HelloWorldWebServicePortType hwwsPortType =
>                                         
> hwws.getHelloWorldWebServicePort( );
>        System.out.println( hwwsPortType.sayHello( ) );
>    }
> }
>
> <?xml version="1.0" encoding="utf-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema

> " xmlns:tns="http://self.org/" attributeFormDefault="unqualified"  
> elementFormDefault="qualified" targetNamespace="http://self.org/">
>  <xsd:element name="SayHello" type="tns:SayHello"/>
>  <xsd:complexType name="SayHello">
>    <xsd:sequence/>
>  </xsd:complexType>
>  <xsd:element name="SayHelloResponse" type="tns:SayHelloResponse"/>
>  <xsd:complexType name="SayHelloResponse">
>    <xsd:sequence>
>      <xsd:element minOccurs="0" name="return" type="xsd:string"/>
>    </xsd:sequence>
>  </xsd:complexType>
> </xsd:schema>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions name="HelloWorldWebService" targetNamespace="http://self.org/ 
> " xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://self.org/ 
> " xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/

> ">
>  <wsdl:types>
> <schema xmlns="http://www.w3.org/2001/XMLSchema">
> <import namespace="http://self.org/"  
> schemaLocation="helloworldwebservice_schema1.xsd"/>
> </schema>
>  </wsdl:types>
>  <wsdl:message name="SayHello">
>    <wsdl:part name="parameters" element="tns:SayHello">
>    </wsdl:part>
>  </wsdl:message>
>  <wsdl:message name="SayHelloResponse">
>    <wsdl:part name="parameters" element="tns:SayHelloResponse">
>    </wsdl:part>
>  </wsdl:message>
>  <wsdl:portType name="HelloWorldWebServicePortType">
>    <wsdl:operation name="SayHello">
>      <wsdl:input name="SayHello" message="tns:SayHello">
>    </wsdl:input>
>      <wsdl:output name="SayHelloResponse"  
> message="tns:SayHelloResponse">
>    </wsdl:output>
>    </wsdl:operation>
>  </wsdl:portType>
>  <wsdl:binding name="HelloWorldWebServiceSoapBinding"  
> type="tns:HelloWorldWebServicePortType">
>    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http

> "/>
>    <wsdl:operation name="SayHello">
>      <soap:operation soapAction="" style="document"/>
>      <wsdl:input name="SayHello">
>        <soap:body use="literal"/>
>      </wsdl:input>
>      <wsdl:output name="SayHelloResponse">
>        <soap:body use="literal"/>
>      </wsdl:output>
>    </wsdl:operation>
>  </wsdl:binding>
>  <wsdl:service name="HelloWorldWebService">
>    <wsdl:port name="HelloWorldWebServicePort"  
> binding="tns:HelloWorldWebServiceSoapBinding">
>      <soap:address location = "http://localhost:8080/HelloWorldWebService/services/HelloWorldWebServicePort

> "/>
>    </wsdl:port>
>  </wsdl:service>
> </wsdl:definitions>


-- 
Freeman Fang

------------------------

FuseSource: http://fusesource.com
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message