There was issue in my client, which I fixed.

Now I am getting request in the SOAP Monitor. 

But How can I get response from MyService. MySerive is the Standard
service provided by Axis2. I want to call echo Operation of that
Service.

Thanks

Sunil

-----Original Message-----
From: Sunil Choudhari -X (suchaudh - Satyam at Cisco) 
Sent: Wednesday, December 06, 2006 2:10 PM
To: '[email protected]'
Subject: WS Addressing in Axis 2.0 (Ver 1.0) ReplyTo

Hi,

I am not able to send my service response to other service.

Find below Service Code:
import javax.xml.namespace.QName;

import org.apache.axiom.om.OMAbstractFactory;
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.context.MessageContext;
import org.apache.axis2.context.OperationContext;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.wsdl.WSDLConstants;

public class MutliHopRedirectService1 {
         private final String applicationNamespaceName =
"http://sunilfromws.org/";; 
         private final String echoStringResponse = "echoStringResponse";
         private final String EchoStringReturn = "EchoStringReturn";
         private final String Text = "Text";
         private final String Sequence = "Sequence";
         
        private MessageContext inMsgCtx;
        
        public void setOperationContext(OperationContext opctx) 
    throws AxisFault {
                inMsgCtx =
opctx.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        }
        
        public OMElement echoRedirect(OMElement ome) throws Exception{
                
                Options oldOptions = inMsgCtx.getOptions();
            String messageID = inMsgCtx.getMessageID();
            System.out.println("Message ID .." + messageID);
            //EndpointReference FromEPR = oldOptions.getFrom();
            //System.out.println("From EPR.."+FromEPR.getAddress());
           
            EndpointReference targetEPR = oldOptions.getReplyTo();
            System.out.println("Reply to
TargetEPR.."+targetEPR.getAddress());
            String action = oldOptions.getAction();
            System.out.println("Action..."+action);
            
                //Return
                OMElement textElem = ome.getFirstChildWithName(new QName
(applicationNamespaceName,Text));
        OMElement sequenceElem = ome.getFirstChildWithName(new QName
(applicationNamespaceName,Sequence));

        if (textElem==null)
            throw new Exception ("'Text' element is not present as a
child of the 'echoString' element");
        if (sequenceElem==null)
            throw new Exception ("'Sequence' element is not present as a
child of the 'echoString' element");

        String textStr = textElem.getText();
        String sequenceStr = sequenceElem.getText();

        System.out.println("'EchoString' service got text '" + textStr +
"' for the sequence '" + sequenceStr + "'");

                OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace applicationNamespace =
fac.createOMNamespace(applicationNamespaceName,"ns1");
        OMElement echoStringResponseElem =
fac.createOMElement(echoStringResponse, applicationNamespace);
        OMElement echoStringReturnElem =
fac.createOMElement(EchoStringReturn, applicationNamespace);
        String  resultText = textStr + "---" + sequenceStr;
        echoStringReturnElem.setText(resultText);
        echoStringResponseElem.addChild(echoStringReturnElem);
                
        return echoStringResponseElem;
        }
        
public void echoRedirectIn(OMElement ome) throws Exception{
                
                Options oldOptions = inMsgCtx.getOptions();
            String messageID = inMsgCtx.getMessageID();
            System.out.println("Message ID .." + messageID);
            //EndpointReference FromEPR = oldOptions.getFrom();
            //System.out.println("From EPR.."+FromEPR.getAddress());
           
            EndpointReference targetEPR = oldOptions.getReplyTo();
            System.out.println("Reply to
TargetEPR.."+targetEPR.getAddress());
            String action = oldOptions.getAction();
            System.out.println("Action..."+action);
            
                //Return
                OMElement textElem = ome.getFirstChildWithName(new QName
(applicationNamespaceName,Text));
        OMElement sequenceElem = ome.getFirstChildWithName(new QName
(applicationNamespaceName,Sequence));

        if (textElem==null)
            throw new Exception ("'Text' element is not present as a
child of the 'echoString' element");
        if (sequenceElem==null)
            throw new Exception ("'Sequence' element is not present as a
child of the 'echoString' element");

        String textStr = textElem.getText();
        String sequenceStr = sequenceElem.getText();

        System.out.println("'EchoString' service got text '" + textStr +
"' for the sequence '" + sequenceStr + "'");

                OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace applicationNamespace =
fac.createOMNamespace(applicationNamespaceName,"ns1");
        OMElement echoStringResponseElem =
fac.createOMElement(echoStringResponse, applicationNamespace);
        OMElement echoStringReturnElem =
fac.createOMElement(EchoStringReturn, applicationNamespace);
        String  resultText = textStr + "---" + sequenceStr;
        echoStringReturnElem.setText(resultText);
        echoStringResponseElem.addChild(echoStringReturnElem);
                
       //return echoStringResponseElem;
        }

}

Client:

public class Service1Client {
        private final static String applicationNamespaceName =
"http://sunilfromws.org/";; 
    private final static String echoString = "echoString";
    private final static String echoStringIn = "echoStringIn";
    private final static String Text = "Text";
    private final static String Sequence = "Sequence";
 
    private static String toEPR =
"http://127.0.0.1:8080/Axis2/services/MutliHopRedirectService1";;
    private static String targetReplyEPR =
"http://127.0.0.1:8080/Axis2/services/MyServive/echo";; 
     private static String CLIENT_REPO_PATH = "C:/Apache/addressclient";

    public static void main(String[] args) throws Exception {
    
        System.out.println("Calling getEchoString");
        getEchoString();
        System.out.println("Complete getEchoString");
        
        System.out.println("Calling getEchoStringIn");
        getEchoStringIn();
        System.out.println("Complete getEchoStringIn");
        
    }

    private static void getEchoString()throws Exception{
        
        String axis2_xml = CLIENT_REPO_PATH + File.separator
+"client_axis2.xml";
        //Add
        EndpointReference objtargetReplyEPR = new
EndpointReference(targetReplyEPR);
        
        ConfigurationContext configContext =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLI
ENT_REPO_PATH,axis2_xml);
        ServiceClient serviceClient = new ServiceClient
(configContext,null);

        Options clientOptions = new Options ();
             
        //Normal Setting
        clientOptions.setTo(new EndpointReference (toEPR));
        clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
        clientOptions.setAction("urn:echoRedirect");
        
        
        serviceClient.setOptions(clientOptions);
        
        OMElement theelem =
serviceClient.sendReceive(getEchoOMBlock("echo1","sequence1",echoString)
);
              
         System.out.println("Complete");
        
       // writeOM(theResult);
    }
 private static void getEchoStringIn()throws Exception{
        
        String axis2_xml = CLIENT_REPO_PATH + File.separator
+"client_axis2.xml";
        
        EndpointReference objtargetReplyEPR = new
EndpointReference(targetReplyEPR);
         
        //ConfigurationContext configContext =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLI
ENT_REPO_PATH,null);
        ConfigurationContext configContext =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLI
ENT_REPO_PATH,axis2_xml);
        ServiceClient serviceClient = new ServiceClient
(configContext,null);

        Options clientOptions = new Options ();
          
        clientOptions.setReplyTo(objtargetReplyEPR);
        clientOptions.setProperty(AddressingConstants.WSA_REPLY_TO,
objtargetReplyEPR);
               
        //Normal Setting
        clientOptions.setTo(new EndpointReference (toEPR));
        clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
        clientOptions.setAction("urn:echoRedirectIn");
        clientOptions.setUseSeparateListener(true);
        
        serviceClient.setOptions(clientOptions);
        
 
serviceClient.fireAndForget(getEchoOMBlock("echo1","sequence1",echoStrin
gIn));
 
//serviceClient.fireAndForget(getEchoOMBlock("echo1","sequence1"));
        
         System.out.println("Complete");
        
       // writeOM(theResult);
    }

    private static OMElement getEchoOMBlock(String text, String
sequenceKey, String Operationname) {
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace applicationNamespace =
fac.createOMNamespace(applicationNamespaceName,"ns1");
        OMElement echoStringElement = fac.createOMElement(Operationname,
applicationNamespace);
        OMElement textElem =
fac.createOMElement(Text,applicationNamespace);
        OMElement sequenceElem =
fac.createOMElement(Sequence,applicationNamespace);

        textElem.setText(text);
        sequenceElem.setText(sequenceKey);
        echoStringElement.addChild(textElem);
        echoStringElement.addChild(sequenceElem);
        System.out.println("Client Side..");
        writeOM(echoStringElement);
        
        return echoStringElement;
    }
    
    public static void writeOM(OMElement lineItem){
//      Seralize the O/p
        try{
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        XMLStreamWriter writer = xof.
           createXMLStreamWriter(System.out);
           lineItem.serialize(writer);
           writer.flush();
        }catch(Exception ex){
                ex.printStackTrace();
        }
    }
}
And Service.xml

<service name="MutliHopRedirectService1">
    <description>
        This is a sample Web Service with One operation
MutliHopRedirectService1
    </description>
    <parameter name="ServiceClass" locked="false">package
com.axis.addressing.redirect.MutliHopRedirectService1</parameter>
    <operation name="echoRedirect">
        <messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
        <actionMapping>urn:echoRedirect</actionMapping>
    </operation>
    <operation name="echoRedirectIn">
        <messageReceiver
class="org.apache.axis2.receivers.RawXMLINMessageReceiver"/>
        <actionMapping>urn:echoRedirectIn</actionMapping>
    </operation>
 

</service>

Whenever client calls " echoRedirectIn" I am not getting any
request/response entry in SOAP monitor.

Thanks

Sunil

-----Original Message-----
From: S. Sharif [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 01, 2006 5:36 PM
To: [email protected]
Subject: [Axis2] Question: Axis2 Quick Start Guide, the 5 approaches for
creating web services (POJO, AXIOM, ADB, XMLBeans, JiBX)


Hi,
I am new to Axis/Axis2.  I stumbled into Axis2 earlier
this week, while trying to find something that would
make developing web services in Java less difficult  I
have started looking at Axis2 during the last couple
of days, downloaded it, installed it, ran it, and read
through some docs.

I am working on a project, that already has several
web services that were previously developed using some
proprietary Novell software tool.  Now I have been
tasked to look into converting these web services to
Java.

I don't have a wsdl file.  If there is one, then the
Novell web service development tool probabley
generates it behind the scenes somewhere.  The web
services currently take in input as a request xml
document and return a response xml document.  So I
know what the input xml and output xml looks like for
each one of the web services, but I don't have the
wsdl.

Now, I am trying to figure out what is the best and
fastest way for me to convert these web services to
Java.

I read through the quick start guide for Axis2 at

http://ws.apache.org/axis2/1_1/quickstartguide.html

The guide outlines 5 different approaches (POJO,
AXIOM, ADB, XMLBeans, JiBX).  I have read through the
guide, but I can't help not being confused over which
approach I should go with.  I would like some help on
deciding which approach is best for my situation.

Any help is very much appreciated.

Thanks.



**********************************************************
* Saladin Sharif
* e-mail:  [EMAIL PROTECTED]
* Visit homepage @ http://gaia.ecs.csus.edu/~sharifs
**********************************************************


 
________________________________________________________________________
____________
Want to start your own business?
Learn how on Yahoo! Small Business.
http://smallbusiness.yahoo.com/r-index

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  • WS Addressing in Axis 2.... Sunil Choudhari -X \(suchaudh - Satyam at Cisco\)
    • RE: WS Addressing i... Sunil Choudhari -X \(suchaudh - Satyam at Cisco\)

Reply via email to