Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Xfire binding in Web Services using JAXB

843833Dec 5 2008
Hi,
I'm trying to run a simple Web Service using Xfire binding with Jaxb. I have created the project and deployed it in the Tomcat server. Its a simple service which takes the object and returns it back. Now when i send the SOAP message, the Xml is not being converted into the object and I'm receiving the following exception:
Exception in thread "main" org.codehaus.xfire.fault.XFireFault: Not enough message parts were received for the operation.
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:387)
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:75)
at org.codehaus.xfire.client.Client.invoke(Client.java:335)
at org.codehaus.xfire.client.Client.invoke(Client.java:349)
at com.mybank.xfire.example.Client.main(Client.java:40)
The interface file is
@WebService(name = "Banking", targetNamespace = "http://com.mybank.xfire.example.model")
public interface IBankingService {

    @WebMethod
    @WebResult(name="response", targetNamespace="http://com.mybank.xfire.example.model")
    public Customer testMethod(@WebParam(name = "customer")
            Customer customer);


} 
The implementation class is :
@WebService(endpointInterface="com.mybank.xfire.example.IBankingService", serviceName="Banking")
@SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
public class BankingService implements IBankingService {

    //Default constructor.
    public BankingService(){    
    }

    public Customer testMethod(Customer customer) {
        // TODO Auto-generated method stub
        System.err.println("In test method: "+ customer);
        return customer;
    }


} 
The Customer bean is generated by JAXB for the following xsd:
<xs:schema elementFormDefault="qualified" targetNamespace="http://com.mybank.xfire.example.model" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Customer">
  <xs:complexType>
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="Name" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="Number" type="xs:int" />
    </xs:sequence>
  </xs:complexType>
  </xs:element>
</xs:schema>
My client is as follows:
    public static void main(String[] args) throws MalformedURLException, Exception {
        // TODO Auto-generated method stub
        //Convert Soap xml to String
        Reader reader = new FileReader("request.xml");
        String str = StreamUtils.readStream(reader);

        org.codehaus.xfire.client.Client client = new org.codehaus.xfire.client.Client(new URL("http://localhost:8080/Xfire/services/Banking?wsdl"));
        Object[] param = new Object[1];
        param[0] = str;
        Object[] result = client.invoke("testMethod", param);
        System.err.println(result[0]);

    } 
If anybody can please tell me the mistake if any.

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 2 2009
Added on Dec 5 2008
0 comments
1,196 views