Hi Paul,
I have attached the files I am using.
thanks a lot

Regards,
Claire

Paul Fremantle wrote:
It looks like your sample code is wrong. Can you post it so we can see?

Thanks!
Paul

On Tue, May 12, 2009 at 8:05 AM, Claire Loto <[email protected]> wrote:
Hi,
I am trying to run a test client in Axis2 but i got this error:
log4j:WARN No appenders could be found for logger
(org.apache.axis2.util.Loader).
log4j:WARN Please initialize the log4j system properly.
org.apache.axis2.AxisFault: Transport out has not been set
  at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:439)
  at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:330)
  at
org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
  at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:520)
  at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:500)
  at org.example.www.helloaxis2.helloClient.main(helloClient.java:37)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

can anyone please help me?

thanks,

Claire




package org.example.www.helloaxis2;

/**
 * Created by IntelliJ IDEA.
 * User: Sajal Dutta
 * Date: May 7, 2009
 * Time: 5:04:00 PM
 * To change this template use File | Settings | File Templates.
 */
import java.io.StringWriter;
import javax.xml.stream.*;
import org.apache.axiom.om.*;
import org.apache.axis2.*;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.Options;

public class helloClient {
    //specify the endpoint reference
    private static EndpointReference targetEPR = new EndpointReference(
    "http://localhost:8080/axis2/services/helloAxis2";);
    public static void main(String[] args) {
        try {
            OMFactory fac = OMAbstractFactory.getOMFactory();
            OMNamespace omNs = fac.createOMNamespace(
            "http://www.example.org/helloAxis2/";, "helloAxis2");
            //compose the request element
            OMElement request = fac.createOMElement("Request", omNs);
            request.addChild(fac.createOMText("MADMUC"));
            Options options = new Options();
            //specify sender options: target, transport protocol, and soap 
action
            options.setTo(targetEPR);
            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
            
options.setAction("http://localhost:8080/axis2/services/helloAxis2";);
            ServiceClient sender = new ServiceClient();
            sender.setOptions(options);
            OMElement result = sender.sendReceive(request);
            //print out the response
            StringWriter writer = new StringWriter();
            result.serialize(XMLOutputFactory.newInstance()
            .createXMLStreamWriter(writer));
            writer.flush();
            System.out.println(writer.toString());
        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        } catch (XMLStreamException e) {
            e.printStackTrace();
        }
    }
}
        /**
        * HelloAxis2MessageReceiverInOut.java
        *
        * This file was auto-generated from WSDL
        * by the Apache Axis2 version: 1.2 Apr 27, 2007 (04:14:19 IST)
        */
        package org.example.www.helloaxis2;

        /**
        *  HelloAxis2MessageReceiverInOut message receiver
        */

        public class HelloAxis2MessageReceiverInOut extends 
org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver{


        public void invokeBusinessLogic(org.apache.axis2.context.MessageContext 
msgContext, org.apache.axis2.context.MessageContext newMsgContext)
        throws org.apache.axis2.AxisFault{

        try {

        // get the implementation class for the Web Service
        Object obj = getTheImplementationObject(msgContext);

        HelloAxis2Skeleton skel = (HelloAxis2Skeleton)obj;
        //Out Envelop
        org.apache.axiom.soap.SOAPEnvelope envelope = null;
        //Find the axisOperation that has been set by the Dispatch phase.
        org.apache.axis2.description.AxisOperation op = 
msgContext.getOperationContext().getAxisOperation();
        if (op == null) {
        throw new org.apache.axis2.AxisFault("Operation is not located, if this 
is doclit style the SOAP-ACTION should specified via the SOAP Action to use the 
RawXMLProvider");
        }

        java.lang.String methodName;
        if(op.getName() != null & (methodName = 
org.apache.axis2.util.JavaUtils.xmlNameToJava(op.getName().getLocalPart())) != 
null){

        

            if("sayHello".equals(methodName)){
                
                org.apache.axiom.om.OMElement response1 = null;
                        org.apache.axiom.om.OMElement wrappedParam =
                                                             
(org.apache.axiom.om.OMElement)fromOM(
                                    
msgContext.getEnvelope().getBody().getFirstElement(),
                                    org.apache.axiom.om.OMElement.class,
                                    
getEnvelopeNamespaces(msgContext.getEnvelope()));
                                                
                                               response1 =
                                                   
                                                   
                                                         
skel.sayHello(wrappedParam)
                                                    ;
                                            
                                        envelope = 
toEnvelope(getSOAPFactory(msgContext), response1, false);
                                    
            } else {
              throw new RuntimeException("method not found");
            }
        

        newMsgContext.setEnvelope(envelope);
        }
        }
        catch (Exception e) {
        throw org.apache.axis2.AxisFault.makeFault(e);
        }
        }
        
        //
        private  org.apache.axiom.om.OMElement fromOM(
        org.apache.axiom.om.OMElement param,
        java.lang.Class type,
        java.util.Map extraNamespaces){
        return param;
        }

        private  org.apache.axiom.om.OMElement  
toOM(org.apache.axiom.om.OMElement param, boolean optimizeContent){
        return param;
        }

        private org.apache.axiom.soap.SOAPEnvelope 
toEnvelope(org.apache.axiom.soap.SOAPFactory factory, 
org.apache.axiom.om.OMElement param, boolean optimizeContent){
        org.apache.axiom.soap.SOAPEnvelope envelope = 
factory.getDefaultEnvelope();
        envelope.getBody().addChild(param);
        return envelope;
        }

        /**
        *  get the default envelope
        */
        private org.apache.axiom.soap.SOAPEnvelope 
toEnvelope(org.apache.axiom.soap.SOAPFactory factory){
        return factory.getDefaultEnvelope();
        }

    

        /**
        *  A utility method that copies the namepaces from the SOAPEnvelope
        */
        private java.util.Map 
getEnvelopeNamespaces(org.apache.axiom.soap.SOAPEnvelope env){
        java.util.Map returnMap = new java.util.HashMap();
        java.util.Iterator namespaceIterator = env.getAllDeclaredNamespaces();
        while (namespaceIterator.hasNext()) {
        org.apache.axiom.om.OMNamespace ns = (org.apache.axiom.om.OMNamespace) 
namespaceIterator.next();
        returnMap.put(ns.getPrefix(),ns.getNamespaceURI());
        }
        return returnMap;
        }

        private org.apache.axis2.AxisFault createAxisFault(java.lang.Exception 
e) {
        org.apache.axis2.AxisFault f;
        Throwable cause = e.getCause();
        if (cause != null) {
            f = new org.apache.axis2.AxisFault(e.getMessage(), cause);
        } else {
            f = new org.apache.axis2.AxisFault(e.getMessage());
        }

        return f;
    }

        }//end of class
    
    /**
     * HelloAxis2Skeleton.java
     *
     * This file was auto-generated from WSDL
     * by the Apache Axis2 version: 1.2 Apr 27, 2007 (04:14:19 IST)
     */
    package org.example.www.helloaxis2;

    import org.apache.axiom.om.OMElement;
    import org.apache.axiom.om.OMNamespace;
    import org.apache.axiom.om.OMAbstractFactory;
    import org.apache.axiom.om.OMFactory;

    /**
     *  HelloAxis2Skeleton java skeleton for the axisService
     */
public class HelloAxis2Skeleton {
    public org.apache.axiom.om.OMElement sayHello(
    org.apache.axiom.om.OMElement param0)
    {
        OMFactory fac = OMAbstractFactory.getOMFactory();
        //create a namespace
        OMNamespace omNs = fac.createOMNamespace(
        "http://www.example.org/helloAxis2/";, "helloAxis2");
        //create an element using the namespace
        OMElement response = fac.createOMElement("Reponse", omNs);
        //get the text content of request message, compose the content of
        //response message, and add it to the element
        response.addChild(fac.createOMText("Hello, " + param0.getText()));
        return response;
    }
}

Attachment: helloAxis2.wsdl
Description: XML document

Reply via email to