Hi ,
I am trying to build a Sample web service using Xfire and spring which will return some string(Test Service).
ClaimContactDataService.java
IClaimContactDataService.javaCode:public class ClaimContactDataService extends BusinessService implements IClaimContactDataService { public String getClaimContacts() throws BusinessServiceException { // TODO Auto-generated method stub return "Test Service"; } }
To generate wsdl: It is generating.Code:public interface IClaimContactDataService extends IBusinessService { String getClaimContacts() throws BusinessServiceException; }
Src/Integration-client-ab.xml
Code:<bean id="claimContactDataBusinessServiceClient" class="org.codehaus.xfire.spring.remoting.XFireClientFactoryBean" p:lookupServiceOnStartup="false" p:serviceClass="com.....integration.ab.business.service.IClaimContactData" p:outHandlers-ref="clientAuthenticationHandler" p:wsdlDocumentUrl-ref="claimContactDataWsdlUrl" /> <bean id="claimContactDataWsdlUrl" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" p:targetClass="com.....integration.ab.properties.BusinessServiceClientProperties" p:targetMethod="getClaimContactDataWsdlUrl" />
Integration-service.xml
Code:<bean id="claimContactDataBusinessService" class="com…….claim.dao.service.ClaimContactDataService"/> services-servlet.xml <bean id="claimContactDataWebService" class="org.codehaus.xfire.spring.remoting.XFireExporter" p:serviceFactory-ref="xfire.serviceFactory" p:xfire-ref="xfire" p:serviceBean-ref="claimContactDataBusinessService" p:serviceClass="com.....integration.ab.business.claim.dao.service.IClaimContactDataService"/> <context:property-placeholder location="classpath:jdbc.properties, classpath:com/.../integration/common/properties/mail.properties" /> <import resource="/Integration-service.xml" /> <import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />
WEDL File:
------------
Client.javaCode:<?xml version="1.0" encoding="UTF-8" ?> - <wsdl:definitions targetNamespace="http://service.dao.claim.business.ab.integration.....com" xmlns:tns="http://service.dao.claim.business.ab.integration.....com" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://request.domain.ab.integration.....com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns3="http://exception.common.integration.....com" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:ns2="http://response.domain.ab.integration.....com" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> - <wsdl:types> - <xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://request.domain.ab.integration.....com" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <xsd:complexType name="ClaimContactRequest"> - <xsd:sequence> <xsd:element minOccurs="0" name="contacts" nillable="true" type="xsd:string" /> </xsd:sequence> </xsd:complexType> </xsd:schema> - <xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.dao.claim.business.ab.integration.....com" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <xsd:element name="getClaimContacts"> - <xsd:complexType> - <xsd:sequence> <xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="ns1:ClaimContactRequest" /> </xsd:sequence> </xsd:complexType> </xsd:element> - <xsd:element name="getClaimContactsResponse"> - <xsd:complexType> - <xsd:sequence> <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="ns2:ClaimContactResponse" /> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="BusinessServiceException" type="ns3:BusinessServiceException" /> </xsd:schema> - <xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://response.domain.ab.integration.....com" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <xsd:complexType name="ClaimContactResponse"> - <xsd:sequence> <xsd:element minOccurs="0" name="contacts" nillable="true" type="xsd:string" /> </xsd:sequence> </xsd:complexType> </xsd:schema> - <xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://exception.common.integration.....com" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:complexType name="BusinessServiceException" /> </xsd:schema> </wsdl:types> - <wsdl:message name="BusinessServiceException"> <wsdl:part name="BusinessServiceException" element="tns:BusinessServiceException" /> </wsdl:message> - <wsdl:message name="getClaimContactsResponse"> <wsdl:part name="parameters" element="tns:getClaimContactsResponse" /> </wsdl:message> - <wsdl:message name="getClaimContactsRequest"> <wsdl:part name="parameters" element="tns:getClaimContacts" /> </wsdl:message> - <wsdl:portType name="IClaimContactDataServicePortType"> - <wsdl:operation name="getClaimContacts"> <wsdl:input name="getClaimContactsRequest" message="tns:getClaimContactsRequest" /> <wsdl:output name="getClaimContactsResponse" message="tns:getClaimContactsResponse" /> <wsdl:fault name="BusinessServiceException" message="tns:BusinessServiceException" /> </wsdl:operation> </wsdl:portType> - <wsdl:binding name="IClaimContactDataServiceHttpBinding" type="tns:IClaimContactDataServicePortType"> <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> - <wsdl:operation name="getClaimContacts"> <wsdlsoap:operation soapAction="" /> - <wsdl:input name="getClaimContactsRequest"> <wsdlsoap:body use="literal" /> </wsdl:input> - <wsdl:output name="getClaimContactsResponse"> <wsdlsoap:body use="literal" /> </wsdl:output> - <wsdl:fault name="BusinessServiceException"> <wsdlsoap:fault name="BusinessServiceException" use="literal" /> </wsdl:fault> </wsdl:operation> </wsdl:binding> - <wsdl:service name="IClaimContactDataService"> - <wsdl:port name="IClaimContactDataServiceHttpPort" binding="tns:IClaimContactDataServiceHttpBinding"> <wsdlsoap:address location="http://localhost:8280/Integration/services/claimContactDataService" /> </wsdl:port> </wsdl:service> </wsdl:definitions>
---------
When I try to call webservice using client I am getting following error, Please help.Code:public class Client { public static void main(String[] args) { Service srvcModel = new ObjectServiceFactory() .create(IClaimContactDataService.class); XFireProxyFactory factory = new XFireProxyFactory(XFireFactory .newInstance().getXFire()); String claimURL = "http://localhost:8280/.../claimContactDataService"; try { IClaimContactDataService srvc = (IClaimContactDataService) factory .create(srvcModel, claimURL); String response = srvc.getClaimContacts(); System.out.println("Response: " + response); } catch (Exception e) { e.printStackTrace(); } } }
Code:org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException at org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11FaultSerializer.java:31) at org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSerializer.java:28) at org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadHeadersHandler.java:111) at org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:67) at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131) at org.codehaus.xfire.client.Client.onReceive(Client.java:406) at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139) at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48) at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26) at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131) at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79) at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114) at org.codehaus.xfire.client.Client.invoke(Client.java:336) at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77) at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57) at $Proxy0.getClaimContacts(Unknown Source) at com...integration.ab.business.claim.dao.service.Client.main(Client.java:25)




Reply With Quote