Submitted on June 17, 2006 - 09:38.
The difference between doing a SOAP invocation and a REST invocation depends on just one line (with default configuration). Just insert the following line of code:
options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
Let's see the complete code snippet.
Options options = new Options();
options.setTo(new EndpointReference(toEpr));
options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
ServiceClient sender = new ServiceClient();
sender.setOptions(options);
OMElement result = sender.sendReceive(getPayload());
If you are invoking a Web service in RESTful manner, make sure the toEpr you give has all the information required to identify the operation and the service that you are invoking. The above code will invoke a resource using HTTP PUT method. To change it to use GET method simply set another option as shown below.
options.setProperty(Constants.Configuration.HTTP_METHOD,
Constants.Configuration.HTTP_METHOD_GET);
Can I change the content type of the request? Yes, you can.
options.setProperty(Constants.Configuration.CONTENT_TYPE, contentType);
The content type should be one of the following:
Invoking with ComplexType input
Hi,
How do i invoke a service which has a complextype input using GET?
The operation is defined like :
where callingSystem,productCode,accountType belong to a complex type :
Could you post the XML
Could you post the XML schema that defines this complex type please.
Thanks,
Keith.
Blog: http://www.keith-chapman.org/
WSDL for my REST service
Hi Keith,
Think the XML i added in the comment got masked. I've attached the WSDL generated using java2wsdl and tweaked per the StudentService REST tutorial i was following.
The java method signature is:
public String getProducts(ProductServiceParameter criteria);
and i am thinking i can invoke it like:
http://localhost:8080/axis2/services/ProductService/products?callingSystem=ABC&productCode=DEF
Please let me know if this is possible or whether my understanding is wrong.
-Joseph
buzz..
Keith, i'm eagerly waiting for your response for this. Has wrpc:style (which is what gets generated) got anything to do with the problem?. I went thru the WSDL2 spec and it mentions the style should be IRI ; but couldn't gather how to fix the WSDL accordingly.