You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Tian Chi <ch...@yahoo.com> on 2008/10/15 01:54:05 UTC

Help! How to get the XML data from a SOAP client and respond with a result XML file?

Hi all, 

I'm new at using Axis2. Don't know how to do this?
Can anyone give me some guidance about this or tell me 
where to find examples/documents about this?

Basically I need to provide a web service and the client program (a SOAP client not using Axis2) will post an XML file to the service. The service program should save the data in the XML file to my database and respond with result message to the client.

I noticed in the Axis2 'Quick Start Guide', there's an example about building the service using AXIOM. I wonder if that's the way to do it.

The function is like

    public OMElement getPrice(OMElement element) throws XMLStreamException {
        element.build();
        element.detach();

        OMElement symbolElement = element.getFirstElement();
        String symbol = symbolElement.getText();

        String returnText = "42";
        Double price = (Double) map.get(symbol);
        if(price != null){
            returnText  = "" + price.doubleValue();
        }
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace omNs =
            fac.createOMNamespace("http://axiom.service.quickstart.samples/xsd", "tns");
        OMElement method = fac.createOMElement("getPriceResponse", omNs);
        OMElement value = fac.createOMElement("price", omNs);
        value.addChild(fac.createOMText(value, returnText));
        method.addChild(value);
        return method;
    }

Does this mean the 'element' object is the XML element sent from the client program?   

Also do I need to do anything else to write (OutputStream stuff) the returned object 'method' to the client?

thanks in advance,

-tian


      

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Help! How to get the XML data from a SOAP client and respond with a result XML file?

Posted by Amila Suriarachchi <am...@gmail.com>.
On Wed, Oct 15, 2008 at 5:24 AM, Tian Chi <ch...@yahoo.com> wrote:

> Hi all,
>
> I'm new at using Axis2. Don't know how to do this?
> Can anyone give me some guidance about this or tell me
> where to find examples/documents about this?
>
> Basically I need to provide a web service and the client program (a SOAP
> client not using Axis2) will post an XML file to the service. The service
> program should save the data in the XML file to my database and respond with
> result message to the client.
>
> I noticed in the Axis2 'Quick Start Guide', there's an example about
> building the service using AXIOM. I wonder if that's the way to do it.
>
> The function is like
>
>    public OMElement getPrice(OMElement element) throws XMLStreamException {
>        element.build();
>        element.detach();
>
>        OMElement symbolElement = element.getFirstElement();
>        String symbol = symbolElement.getText();
>
>        String returnText = "42";
>        Double price = (Double) map.get(symbol);
>        if(price != null){
>            returnText  = "" + price.doubleValue();
>        }
>        OMFactory fac = OMAbstractFactory.getOMFactory();
>        OMNamespace omNs =
>            fac.createOMNamespace("
> http://axiom.service.quickstart.samples/xsd", "tns");
>        OMElement method = fac.createOMElement("getPriceResponse", omNs);
>        OMElement value = fac.createOMElement("price", omNs);
>        value.addChild(fac.createOMText(value, returnText));
>        method.addChild(value);
>        return method;
>    }
>
> Does this mean the 'element' object is the XML element sent from the client
> program?

This is what comes under the SoapBody in your request in case it is soap
binding. for an HTTP binding this is the xml payload it has received.



>
>
> Also do I need to do anything else to write (OutputStream stuff) the
> returned object 'method' to the client?


No. Axis2 do it automatically.

thanks,
Amila.

>
>
> thanks in advance,
>
> -tian
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

Re: Help! How to set the value of SOAPAction for a SOAP service using Axis2?

Posted by Deepal Jayasinghe <de...@opensource.lk>.
Hi Tian,
Have a look at the action mapping section of the following article.

http://wso2.org/library/2060

Deepal

Tian Chi wrote:
> Hi all, 
>
> I'm new to Axis2 and SOAP. I need to create a SOAP service using Axis2.
> I wonder how to set the SOAPAction value so my service will verify the  value when a client program call the service? 
> I assume Axis2 will do the SOAPAction validation automatically as long as I set the value somewhere in my service, right? But how to do that?
>
> thanks in advance,
>
> -tian
>
>
>       
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>   

-- 
Thank you!


http://blogs.deepal.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Help! How to set the value of SOAPAction for a SOAP service using Axis2?

Posted by Tian Chi <ch...@yahoo.com>.
Hi all, 

I'm new to Axis2 and SOAP. I need to create a SOAP service using Axis2.
I wonder how to set the SOAPAction value so my service will verify the  value when a client program call the service? 
I assume Axis2 will do the SOAPAction validation automatically as long as I set the value somewhere in my service, right? But how to do that?

thanks in advance,

-tian


      

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org