My service deployed successfully. And client work correctly if I don’t use objects of classes from my external jar or I don’t use these objects in methods, which are described in service.xml file. Maybe problem in my service.xml?

 

My service class:

 

import user.str.UserString;

import org.apache.axiom.om.OMElement;

 

           

            public class MyService{

                public void ping(OMElement element){

                        System.out.print("ping"+ "-" + element.toString());

                }

                public OMElement echo(OMElement element){

                        //I use external jar

                        UserString.setStr("aaa");

                       

                        System.out.print("echo"+ "-" + element.toString());

                        return element;

                 }

       

           

            }

 

My service.xml:

<?xml version="1.0" encoding="UTF-8"?>

<service >

    <description>

        This is a sample Web Service with two operations, echo and ping.

    </description>

    <parameter name="ServiceClass" locked="false">src.test.MyService</parameter>

    <operation name="echo">

        <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>

        <actionMapping>urn:echo</actionMapping>

    </operation>

     <operation name="ping">

        <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>

        <actionMapping>urn:ping</actionMapping>

    </operation>

 </service>

 

 

My client class:

 

import org.apache.axiom.om.OMAbstractFactory;

import org.apache.axiom.om.OMAttribute;

import org.apache.axiom.om.OMElement;

import org.apache.axiom.om.OMFactory;

import org.apache.axiom.om.OMNamespace;

import org.apache.axis2.AxisFault;

import org.apache.axis2.addressing.EndpointReference;

import org.apache.axis2.client.Options;

import org.apache.axis2.client.ServiceClient;

import org.apache.axis2.context.ConfigurationContext;

import org.apache.axis2.context.ConfigurationContextFactory;

 

public class TestMyService {

 

    public static void main(String arg[]){

        try {

            OMElement payload = getServiceMethod("echo");

            Options options = new Options();

            options.setTo(targetEPR);

            ServiceClient serviceClient = new ServiceClient();

            serviceClient.setOptions(options);

           

            payload.addAttribute("attribute1", "string1", payload.getDefaultNamespace());

                  

            OMElement em = serviceClient.sendReceive(payload);

             /**

              * We have to block this thread untill we send the request , the problem

              * is if we go out of the main thread , then request wont send ,so

              * you have to wait some time :)

              */

            System.out.println(em.toString());

             

           

           

          }

     catch (AxisFault axisFault) {

                 axisFault.printStackTrace();

          }

   

 

    }

     

    /**

     * @return Returns Axiom element containing a method description.

     */

    private static OMElement getServiceMethod(String arg)

    {

        OMFactory factory = OMAbstractFactory.getOMFactory();

        OMNamespace namespace = factory.createOMNamespace(

                "http://test/MyService",

                "MyService");

        OMElement method = factory.createOMElement(arg, namespace);

        return method;

    }

 

    private static EndpointReference targetEPR = new EndpointReference(

            "http://localhost:8080/axis2/services/MyService");

   

}

 

 

Client and Service are implemented in different projects.

 

 

 

 

Best regards, Smirnova Natalya.

MERA NN /EMA/custom software


From: Smirnova, Natalya
Sent: Wednesday, July 12, 2006 3:57 PM
To: 'axis-user@ws.apache.org'
Subject: [Axis2] How web-services works with external jars?

 

I have such problem:

I want to add external jar to build path in my web-service. I use objects of classes from this jar in method, which is described in service.xml. But my client for this method display errors, such follows:

      org.apache.axis2.AxisFault: unknown

      at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:287)

      at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:457)

      at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:399)

      at client.TestMyService.main(TestMyService.java:27)……………………………………………………………

 

 

Best regards, Smirnova Natalya.

MERA NN /EMA/custom software

 

Reply via email to