> >> <?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/">
....... > <soap:Body> > <ns2:SayHelloResponse xmlns:ns2="http://test.soa.faa.gov/"> > <return>Greetings From SOA Hello World running on > Tomcat!</return> > </ns2:SayHelloResponse> > </soap:Body> > </soap:Envelope> There's the problem. The WSDL says the "return" element should be qualified. However, the response doesn't have it qualified. I'll be if you modify the WSDL to have elementFormDefault="unqualified" and regenerate the client, it would work. Dan On Wednesday 12 January 2011 10:13:04 am Michael wrote: > I've created my projects since my first post so come class and interface > names are different, but we are essentially talking about the some thing > here. > > To respond to your comment, my client side code does have an implementation > of the "port type" interface. See the code below (remember the name > changes): > > I'm sure that the problem is on the client side since the Tomcat console > shows the > SOAP messages for the call to the server; the sayHello( ) called message is > mine. See > the console message text below the source code. > > I also just noticed a comment in the HelloWorldPortTypeImpl class. It says > the > class is not complete. Can you provide some info on what I need to > complete it? > > Thanks > > ************ Client ******************** > package gov.faa.soa.test; > > public final class Client > { > public static void main(String args[]) > { > HelloWorld hw = new HelloWorld( ); > HelloWorldPortType hwpt = hw.getHelloWorldPort( ); > System.out.println( hwpt.sayHello( ) ); > } > } > ************************************** > > ************ Port Type ******************** > package gov.faa.soa.test; > > import javax.jws.WebMethod; > import javax.jws.WebResult; > import javax.jws.WebService; > import javax.xml.bind.annotation.XmlSeeAlso; > import javax.xml.ws.RequestWrapper; > import javax.xml.ws.ResponseWrapper; > > /** > * This class was generated by Apache CXF 2.3.0 > * Tue Jan 11 17:56:56 EST 2011 > * Generated source version: 2.3.0 > * > */ > > @WebService(targetNamespace = "http://test.soa.faa.gov/", name = > "HelloWorldPortType") > @XmlSeeAlso({ObjectFactory.class}) > public interface HelloWorldPortType { > > @WebResult(name = "return", targetNamespace = > "http://test.soa.faa.gov/") > @RequestWrapper(localName = "SayHello", targetNamespace = > "http://test.soa.faa.gov/", className = "gov.faa.soa.test.SayHello") > @WebMethod(operationName = "SayHello") > @ResponseWrapper(localName = "SayHelloResponse", targetNamespace = > "http://test.soa.faa.gov/", className = > "gov.faa.soa.test.SayHelloResponse") public java.lang.String sayHello(); > } > ************************************** > > ************ Port Type Implementation ******************** > /** > * Please modify this class to meet your needs > * This class is not complete > */ > > package gov.faa.soa.test; > > import java.util.logging.Logger; > import javax.jws.WebMethod; > import javax.jws.WebResult; > import javax.jws.WebService; > import javax.xml.bind.annotation.XmlSeeAlso; > import javax.xml.ws.RequestWrapper; > import javax.xml.ws.ResponseWrapper; > > /** > * This class was generated by Apache CXF 2.3.0 > * Tue Jan 11 17:56:56 EST 2011 > * Generated source version: 2.3.0 > * > */ > > @javax.jws.WebService( > serviceName = "HelloWorld", > portName = "HelloWorldPort", > targetNamespace = "http://test.soa.faa.gov/", > wsdlLocation = > "http://localhost:8080/TomcatSOAHelloWorld/wsdl/ihelloworld.wsdl?wsdl", > endpointInterface = > "gov.faa.soa.test.HelloWorldPortType") > > public class HelloWorldPortTypeImpl implements HelloWorldPortType { > > private static final Logger LOG = > Logger.getLogger(HelloWorldPortTypeImpl.class.getName()); > > /* (non-Javadoc) > * @see gov.faa.soa.test.HelloWorldPortType#sayHello(* > */ > public java.lang.String sayHello() { > LOG.info("Executing operation sayHello"); > try { > java.lang.String _return = "_return169428188"; > return _return; > } catch (Exception ex) { > ex.printStackTrace(); > throw new RuntimeException(ex); > } > } > > } > ************************************** > > ************ Tomcat Console Message ******************** > Jan 11, 2011 3:36:34 PM > org.apache.cxf.interceptor.AbstractLoggingInterceptor log > INFO: Inbound Message > ---------------------------- > ID: 1 > Address: /TomcatSOAHelloWorld/services/HelloWorldPort > Encoding: UTF-8 > Content-Type: text/xml;charset="utf-8" > Headers: {content-type=[text/xml;charset="utf-8"], > connection=[keep-alive], > host =[localhost:8080], > Content-Length=[160], > SOAPAction=[""], > user-agent=[JAX-WS RI 2.1.6 in JDK 6], > Content-Type=[text/xml;charset="utf-8"], > Accept=[text/xml, multipart/related, text/html, image/gif, image/jpeg, *; > q=.2, */*; q=.2]} > Payload: <?xml version="1.0" ?> > <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> > <S:Body> > <SayHello xmlns="http://test.soa.faa.gov/"/> > </S:Body> > </S:Envelope> > -------------------------------------- > > SayHello( ) in the HelloWorld Web Service was called! > > Jan 11, 2011 3:36:35 PM > org.apache.cxf.interceptor.AbstractLoggingInterceptor log > INFO: Outbound Message > --------------------------- > ID: 1 > Encoding: UTF-8 > Content-Type: text/xml > Headers: {} > Payload: <soap:Envelope > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> > <soap:Body> > <ns2:SayHelloResponse xmlns:ns2="http://test.soa.faa.gov/"> > <return>Greetings From SOA Hello World running on > Tomcat!</return> > </ns2:SayHelloResponse> > </soap:Body> > </soap:Envelope> > -------------------------------------- > ************************************** > > > > ----- Original Message ----- > From: "Michael" <[email protected]> > To: <[email protected]> > Sent: Sunday, January 09, 2011 9:56 AM > Subject: Re: Web Service Method Returns null > > > Thanks, I'll take a look at this. > > > > But, after giving this problem some thought I have another question: > > > > Does the class that implements the web service have to be a Java Bean or > > can in be a POJO? > > > > ----- Original Message ----- > > From: "Freeman Fang" <[email protected]> > > To: <[email protected]> > > Sent: Sunday, January 09, 2011 7:03 AM > > Subject: Re: Web Service Method Returns null > > > > > > 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/HelloWorldWebServic > >> ePort "/> > >> > >> </wsdl:port> > >> > >> </wsdl:service> > >> > >> </wsdl:definitions> > > > > ------------------------ > > > > 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 -- Daniel Kulp [email protected] http://dankulp.com/blog
