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 Prasad Maddela <pr...@gmail.com> on 2011/03/05 16:30:12 UTC

Need Dynamic Client for Webservice developed in Axis2-1.5.1 + Xmlbeans

Hi ,

Require help to have a dynamic client for webservices developed in
Axis2-1.5.1 and Xmlbeans as the binding framework.

I am successfully using code metioned below as dynamic client for invoking
web services written in Axis2-1.5.1 & ADB framework ,

Please mention or guide me as what all changes i have to do in order to make
this code work for invoking webservices
written in Axis2-1.5.1 & Xml-beans.


ServiceClient serviceClient = new ServiceClient();
Options options = new Options();
options.setTo(new EndpointReference(endpointRef));
options.setAction(methodName);
serviceClient.setOptions(options);
OMElement res = serviceClient.sendReceive(createPayLoad(inputXml));
responseXml = res.toString();
System.out.println(responseXml);

// createPayLoad method
parser = XMLInputFactory.newInstance().createXMLStreamReader( new
StringReader(inputXml));
StAXOMBuilder builder = new StAXOMBuilder(OMAbstractFactory.getOMFactory(),
parser);
return documentElement = builder.getDocumentElement();

Thanks & Regards,
M.Prasad Rao

Re: Need Dynamic Client for Webservice developed in Axis2-1.5.1 + Xmlbeans

Posted by robert lazarski <ro...@gmail.com>.
On Sun, Mar 6, 2011 at 12:15 AM, Prasad Maddela
<pr...@gmail.com> wrote:
> Hi Robert,
>
> Thanks for your suggestion.
>
> Url given by you has an example which uses static client stubs but my
> requirement is to have dynamic client similar to the code i have mentioned
> below so that i can have one single webservice utility to invoke
> mulitple webservices by loading the webservice information either from the
> properties file or from db.
>

I myself would approach the problem differently and not use the axis2
and stax api's much directly. But rather, since you would already have
the xmlbean / adb generated classes and methods from your wsdl, you'd
know those names before runtime and therefore you could invoke them
dynamically via Class.forName etc.

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


Re: Need Dynamic Client for Webservice developed in Axis2-1.5.1 + Xmlbeans

Posted by Prasad Maddela <pr...@gmail.com>.
Hi Robert,

Thanks for your suggestion.

Url given by you has an example which uses static client stubs but my
requirement is to have dynamic client similar to the code i have mentioned
below so that i can have one single webservice utility to invoke
mulitple webservices by loading the webservice information either from the
properties file or from db.

Reason for not using ADB framework is i have a requirement where
webservices responses are stored in files and i have to convert xml
into object & object to xml
more than once in the process flow and on each conversion the type
attributes of each element gets added redundantly making the generated xml
itself invalid.

Below is the code generated by the ADB framework which adds all unhandled
attributes of the element,
but problem is type information of the element is added at the start of the
parse() method and if there
is already a type information in the element (ex:  xml form ) that will also
gets added making it duplicate.


 // now run through all any or extra attributes
// which were not reflected until now
*for* (*int* i=0; i < reader.getAttributeCount(); i++) {
*if* (!handledAttributes.contains(reader.getAttributeLocalName(i))) {
             // this is an anyAttribute and we create
             ......
}


FYI , i am using getOMElement().toString() to convert object into String
        and Object.Factory.Parse(null,null) method to convert xml into
object.

Thanks & Regards,
M.Prasad Rao

On Sat, Mar 5, 2011 at 9:11 PM, robert lazarski <ro...@gmail.com>wrote:

> On Sat, Mar 5, 2011 at 12:30 PM, Prasad Maddela
> <pr...@gmail.com> wrote:
> > Hi ,
> >
> > Require help to have a dynamic client for webservices developed in
> > Axis2-1.5.1 and Xmlbeans as the binding framework.
> >
>
> I suggest using this xmlsbean example in the docs to get you started:
>
> http://axis.apache.org/axis2/java/core/tools/CodegenToolReference.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-dev-help@axis.apache.org
>
>

Re: Need Dynamic Client for Webservice developed in Axis2-1.5.1 + Xmlbeans

Posted by robert lazarski <ro...@gmail.com>.
On Sat, Mar 5, 2011 at 12:30 PM, Prasad Maddela
<pr...@gmail.com> wrote:
> Hi ,
>
> Require help to have a dynamic client for webservices developed in
> Axis2-1.5.1 and Xmlbeans as the binding framework.
>

I suggest using this xmlsbean example in the docs to get you started:

http://axis.apache.org/axis2/java/core/tools/CodegenToolReference.html

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