Hello Murugesan,

you seem to have the remote resource (the one identified by the "uri" 
variable) on one hand, but what method do you want to invoke on this 
resource?
You must refer to the Yahoo search API, in order to know how you can 
pass this data.
As I suppose you want to "POST" some data, you can use the following code:

ClientResource demoResource = new ClientResource(uri);
// Create the representation to send
StringRepresentation rep = new StringRepresentation("<a>b</a>", 
MediaType.APPLICATION_XML);
// POST the representation
demoResource.post(rep).write(System.out);

or the following:

Client client = new Client(Protocol.HTTP);
// Create the representation to send
StringRepresentation rep = new StringRepresentation("<a>b</a>", 
MediaType.APPLICATION_XML);
// POST the representation
client.post(uri, rep).getEntity().write(System.out);

You can find other kinds of representations (instead of 
StringRepresentation) inside the org.restlet.xml extension.

Best regards,
Thierry Boileau


> Hi,
> I am new to Restlet and restful webservices. I want to pass a String(XML 
> format) into request and invoke the Restful webservices.
>
> Below code is working for normal call.
>
> import java.io.IOException;
>
> import org.restlet.Client;
> import org.restlet.data.Protocol;
>
> public class SimpleClient {
>    public static void main(String [] args) throws IOException {
>      String uri =  
> "http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=finances&format=pdf";
>  ;
>      Client client = new Client(Protocol.HTTP);
>      client.get(uri).getEntity().write(System.out);
>    }
> }
>
> But i need to pass String as XML format into requset. How to do that?
>
> Thanks in advance.
>
> Regards,
> Murugesan
>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2434575
>
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2434577

Reply via email to