Hi, 

On 30 nov. 2011, at 11:59, Sergey Beryozkin wrote:

> Hi
> On 30/11/11 09:29, Diana ALLAM wrote:
>> Hello,
>> thank you for your reply.
>> 
>> Currently, I am doing a study about well dynamic typing of web service and I 
>> choose cxf
>> to run some examples.
>> In fact, for SOAP/WS* services, there is a standard used , wsdl files, which 
>> are generated by a web service.
>> A client can use this wsdl to generate an appropriated interface in java to 
>> build an appropriated request to
>> the designed web service. Thus, I can say, following this way, there must 
>> not be any typing errors.
>> But for Restful services, the situation differs a bit. There is a WADL files 
>> to describe the web services like the
>> WSDL files in SOAP/WS*, but WADL still not a standard.
> 
> it's a W3C submission and it appears users who work with RESTful services and 
> happen to see the benefit of providing the documents such as WADL just use 
> WADL;

Yes, but I mean that WADL is not yet used by all Restful services like the WSDL 
for WS*
> 
>> My question is, if a restful web service doesn't define a WADL, thus the 
>> client can't generate in java the appropriated
>> classes (like using wadltojava), then how he can know the type of messages?
>> I suppose that in the absence of a WADL for a web service, there is a text 
>> description file describing all methods and
>> there messages types. Thus, the client has to read this document to know how 
>> to build his messages.
>> Here, he can make mistakes by sending to a restful resource an inappropriate 
>> data.
>> 
>> Is my reasoning correct about that?
> That may not be that big an issue actually - unless we are talking about the 
> completely generic clients, but indeed, with the fluent HTTP-centric API one 
> just needs to apply a bit more care to making sure the correct messages are 
> sent and such - but as I said if the code
> were not corect it work it would fail at the first try, then the user would 
> go and check the SLA or whatever and update the code.
> In CXF we support both styles:
> http://cxf.apache.org/docs/jax-rs-client-api.html
> so choose the option you like or experiment with both ones
> 
> Proxies can also be generated from the existing WADLs:
> http://cxf.apache.org/docs/jaxrs-services-description.html
> 
> even WSDLs can be used as the input (this option is a bit more involved)

Thank you a lot for these informations.
I can deduce that from the client developer side, calling a WS* web service is 
more standardized than a restful one,
because the user can get a WSDL and creates properly a proxy, while for Rest it 
 will not be the case if 
no Wadl is provided.

In your opinion, isn't it an advantage for WS*? Doesn't it an annoying checking 
problem for restful's clients?
Will WADL be defined for all Restful services in the coming days, such as WSDL 
for WS* services today?

Regards,

Diana


> Sergey
>> 
>> 
>> Regards,
>> 
>> Diana
>> 
>> On 29 nov. 2011, at 18:01, Sergey Beryozkin wrote:
>> 
>>> Hi
>>> 
>>> On 29/11/11 15:33, Diana ALLAM wrote:
>>>> Hello,
>>>> 
>>>> After using the restful examples in the "samples" directory of cxf 
>>>> distribution, I distinguished
>>>> two types of restful request for "put/post" CRUD methods.
>>>> 1) the first one is by sending a request with an xml object description 
>>>> (samples ->   jax_rs ->   basic)
>>>> Follows, there is a part of the code example for calling the put method by 
>>>> using an input file containing the "customer" xml code:
>>>>         // Sent HTTP PUT request to update customer info
>>>>         System.out.println("\n");
>>>>         System.out.println("Sent HTTP PUT request to update customer 
>>>> info");
>>>>         Client client = new Client();
>>>>         String inputFile = 
>>>> client.getClass().getResource("update_customer.xml").getFile();
>>>>         URIResolver resolver = new URIResolver(inputFile);
>>>>         File input = new File(resolver.getURI());
>>>>         PutMethod put = new 
>>>> PutMethod("http://localhost:8080/CustomerRestfullTest/jaxrs/customerservice/customers";);
>>>>         RequestEntity entity = new FileRequestEntity(input, "text/xml; 
>>>> charset=ISO-8859-1");
>>>>         put.setRequestEntity(entity);
>>>>         HttpClient httpclient = new HttpClient();
>>>> 
>>>>         try {
>>>>             int result = httpclient.executeMethod(put);
>>>>             System.out.println("Response status code: " + result);
>>>>             System.out.println("Response body: ");
>>>>             System.out.println(put.getResponseBodyAsString());
>>>>             
>>>> System.out.println(put.getResponseHeader(Message.ENDPOINT_ADDRESS));
>>>>         } finally {
>>>>             // Release current connection to the connection pool once you 
>>>> are
>>>>             // done
>>>>             put.releaseConnection();
>>>>         }
>>>> 
>>> 
>>> This is a very old code that will be replaced
>>> 
>>>> 2) the second one is by using an instance of a Java class, here is 
>>>> Customer, instead of getting data from an input file (samples ->   jax_rs 
>>>> ->   basic_https)
>>>> 
>>>>         WebClient wc = WebClient.create(BASE_SERVICE_URL, 
>>>> CLIENT_CONFIG_FILE);
>>>>         Customer customer = new Customer();
>>>>         customer.setId(123);
>>>>         customer.setName("Mary");
>>>>         Response resp = wc.put(customer);
>>>> 
>>>> 
>>>> I prefer to use the second method because in the first method,
>>>> a developer could make mistakes in his input file, then the server will 
>>>> reply by a fault message, while the second
>>>> method allows to avoid such errors as there is a customer object conform 
>>>> to a specified class Customer.
>>>> 
>>>> I think also the second method is more adapted if the client wishes using 
>>>> a wadl file, then by using wadltojava, all the appropriated classes
>>>> are generated (like the Customer class in my previous example).
>>> Agreed
>>>> But my question is, when and why a developer need to use the first method?
>>> 
>>> If developers do prefer using Apache HttpClient for whatever reasons then 
>>> they may want to use that API
>>> 
>>> Cheers, Sergey
>>> 
>>>> And by such a use, the developer doesn't take the risk of sending 
>>>> inadapted data to the server?
>>>> and how the developer knows which data description form (for the customer 
>>>> example, it is an xsd) he must use in this case, if he doesn't have a wadl?
>>>> because I suppose that if he had a wadl then he must use the second method.
>>>> 
>>>> Thank you in advance.
>>>> 
>>>> Regards,
>>>> 
>>>> Diana
>>>> 
>>>> 
>>> 
>>> 
>>> --
>>> Sergey Beryozkin
>>> 
>>> Talend Community Coders
>>> http://coders.talend.com/
>>> 
>>> Blog: http://sberyozkin.blogspot.com
>> 
> 
> 
> -- 
> Sergey Beryozkin
> 
> Talend Community Coders
> http://coders.talend.com/
> 
> Blog: http://sberyozkin.blogspot.com

Reply via email to