[ 
http://issues.apache.org/jira/browse/AXIS2-1817?page=comments#action_12456182 ] 
            
Deepal Jayasinghe commented on AXIS2-1817:
------------------------------------------

The main idea of ServiceClient is to provide a way to invoke a service using 
very XML centric manner , that is why it take and return OMElements. In the 
other hand RPCServiecClient is to invoke a service in very java centric manner 
, but it has nothing to do with soap/rpc , so do not worry :) . As mentioned 
RPCServiceClient is like a wrapper class to ServiceClient in oder to provide a 
convenient API.  

> ServiceClient and RPCServiceClient classes
> ------------------------------------------
>
>                 Key: AXIS2-1817
>                 URL: http://issues.apache.org/jira/browse/AXIS2-1817
>             Project: Apache Axis 2.0 (Axis2)
>          Issue Type: Improvement
>          Components: samples
>         Environment: Linux Fedora5, tomcat 5.5.20, java1.5.0_0.9, Axis2 1.0
>            Reporter: Federica Ciotti
>         Assigned To: Deepal Jayasinghe
>         Attachments: CalcClient.java, MyCalcClient.java, RPC_MyCalcClient.java
>
>
> I have some important doubts on ServiceClient and RPCServiceClient classes.
> In axis I used to do something like this: listProduct = (Vector<Object>) 
> call.invoke(new Object[]{});
> When I migrated to axis2 I thought that ServiceClient was the easiest way to 
> invoke a method just as I did in axis.
> But I find out that I'm forced to use OMElement for parameters and 
> invocation's result in this way (MyCalcClient.java):
>               try{
>                       ServiceClient serviceClient = new ServiceClient();
>                       serviceClient.setOptions(options);
>                       OMFactory fac = OMAbstractFactory.getOMFactory();
>                       OMNamespace omNs = 
> fac.createOMNamespace("http://www.cal.com/calc";, "calc");
>                       OMElement payload = fac.createOMElement(opStr, omNs);
>                       OMElement param1OM = fac.createOMElement("param1", 
> omNs);
>                       OMElement param2OM = fac.createOMElement("param2", 
> omNs);
>                       param1OM.setText(Integer.toString(pi1));
>                       param2OM.setText(Integer.toString(pi2));
>                       payload.addChild(param1OM);
>                       payload.addChild(param2OM);                     
>                       serviceClient.setOptions(options);
>                       OMElement result = serviceClient.sendReceive(payload);
>                       System.out.println(result.toString());
>                       
>               }catch(AxisFault af){af.printStackTrace();}
> and this is not very good if you have complex object returned by methods and 
> complex parameters. 
> Looking at RPCServiceClient i found out an easiest way (class 
> RPC_MyCalcClient.java):
> try{
>                       String opName="add";
>                       EndpointReference targetEPR = new 
> EndpointReference("http://localhost:8080/axis2/services/RPCCalcService/";);
>                       Options options = new Options();
>                       options.setTo(targetEPR);
>                       
> options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
>                       ConfigurationContext 
> configContext=ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,null);
>  
>                       RPCServiceClient sender = new 
> RPCServiceClient(configContext, null);
>                       sender.setOptions(options);
>                       ArrayList<Integer> arg = new ArrayList<Integer>();
>                       Integer a  = new Integer("100"); 
>                       arg.add(a);
>                       Integer b = new Integer("200");
>                       arg.add(b);
>                       QName opAdd = new QName("http:///xsd";, "add");
>                       Object[] params = new Object[] { a, b };
>                       Class[] returnTypes = new Class[] { Integer.class };
>                       Object[] response = sender.invokeBlocking(opAdd, 
> params, returnTypes);
>                       Integer result = (Integer) response[0];
>                       if (result == null) {System.out.println("Null");}
>                       else System.out.println("Result "+ result.toString());
>               }catch(AxisFault a){a.printStackTrace();} 
> If I want something like that: Object[] response = 
> sender.invokeBlocking(opAdd, params, returnTypes);
> I'm forced to use RPCServiceClient?
> RPCServiceClient means that I'm using soap/rpc binding style? 
> Soap/document-style is supported in axis2?
> I've checked the examples in CalculatorService package, in this case a 
> different tecnique is used (CalcClient.java) and a SOAPEnvelope Object is 
> returned by the method invocation: 
>       SOAPEnvelope result = opClient.getMessageContext(
>                                       
> WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope();
> How can I choose one of these different tecniques? 
> Please help me understanding more about and tell me where can I find 
> documentation on this issue.
> Many Thanks
> Federica

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Reply via email to