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 Lev Lvovsky <li...@sonous.com> on 2010/05/06 06:39:07 UTC

axis2 + wsdl 2.0 + REST questions

Hello,

I'm running into some issues in using the wsdl2java application when it comes to outputting code which is able to communicate with a REST-based service.

There are several issues which have come up, so I'll start at the most basic and work my way down:


1.  According to the W3C WSDL documentation, the "service" element is optional (http://www.w3.org/TR/wsdl20/#Description_XMLRep).  However whenever attempting to ingest a WSDL without a service element with wsdl2java.sh, I get null pointer exceptions:

--
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: java.lang.NullPointerException
        at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:271)
        at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
        at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
--

The goal of not including a service element is spelled out in another section of the wsdl docs: http://www.w3.org/TR/wsdl20-primer/#adv-service-references .  Our service is very similar to the example service in that we supply a list of things, which include a link to where the details of those things can be found.  That link may or may not be a link relative to the initial list service, so the idea of just tacking on paths to the original URL as the current service element would have us do is not practical.

2.  When the client makes a request to an unavailable resource (perhaps the details for that resource are no longer available), our service responds with an HTTP code (for example, 410 GONE), as well as an XML response.  It seems that the http transport layer complains before I get a chance to inspect the response - I'm assuming that dealing with this problem is a matter of working with the behavior of the HTTP transport interface?

3.  Outside of HTTP server errors - as I mentioned in the previous issue - we serve an XML response which details the error.  My understanding from the interface element of the WSDL, was that the client could expect to get up to 4 possibly different XML responses from the service - infault/outfault and input/output.  In testing the response handling of the client, whenever I invoke an error from the service, the client complains that it didn't get the response which it expected for the output (no error) response.  I'm assuming I don't have to wrap the response in something like a SOAP envelope to indicate the regular payload versus some fault payload, correct?

Any help input is greatly appreciated!

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


Re: axis2 + wsdl 2.0 + REST questions

Posted by Lev Lvovsky <li...@sonous.com>.
Hi Amila,

On May 8, 2010, at 8:54 PM, Amila Suriarachchi wrote:
>> The goal of not including a service element is spelled out in another section of the wsdl docs: http://www.w3.org/TR/wsdl20-primer/#adv-service-references .  Our service is very similar to the example service in that we supply a list of things, which include a link to where the details of those things can be found.  That link may or may not be a link relative to the initial list service, so the idea of just tacking on paths to the original URL as the current service element would have us do is not practical.

> Axis2 wsdl2java tool assumes a service and binding otherwise it may complicate the code generation. What you can do is to create a wsdl with a service and import the correct wsdl to it. you can keep this wsdl only for generation purposes. 

Can you be more specific with how this can be done?

> 3.  Outside of HTTP server errors - as I mentioned in the previous issue - we serve an XML response which details the error.  My understanding from the interface element of the WSDL, was that the client could expect to get up to 4 possibly different XML responses from the service - infault/outfault and input/output.  In testing the response handling of the client, whenever I invoke an error from the service, the client complains that it didn't get the response which it expected for the output (no error) response.  I'm assuming I don't have to wrap the response in something like a SOAP envelope to indicate the regular payload versus some fault payload, correct?
> 
> for a fault message it is supposed to send a soap fault. And the detail element should have the element you describes in the wsdl. If you use axis2 it does this automatically. 

But our service is explicitly REST-based - is this to say that even if the service is described as being REST by the namespace, it is still expected to give back a SOAP-based response?  Perhaps that's the source of my confusion - I was under the impression that axis2 could deal with generic REST HTTP requests in a completely non-SOAP manner.

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


Re: axis2 + wsdl 2.0 + REST questions

Posted by Amila Suriarachchi <am...@gmail.com>.
On Thu, May 6, 2010 at 10:09 AM, Lev Lvovsky <li...@sonous.com> wrote:

> Hello,
>
> I'm running into some issues in using the wsdl2java application when it
> comes to outputting code which is able to communicate with a REST-based
> service.
>
> There are several issues which have come up, so I'll start at the most
> basic and work my way down:
>
>
> 1.  According to the W3C WSDL documentation, the "service" element is
> optional (http://www.w3.org/TR/wsdl20/#Description_XMLRep).  However
> whenever attempting to ingest a WSDL without a service element with
> wsdl2java.sh, I get null pointer exceptions:
>
> --
> Exception in thread "main"
> org.apache.axis2.wsdl.codegen.CodeGenerationException:
> java.lang.NullPointerException
>        at
> org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:271)
>        at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
>        at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
> --
>
> The goal of not including a service element is spelled out in another
> section of the wsdl docs:
> http://www.w3.org/TR/wsdl20-primer/#adv-service-references .  Our service
> is very similar to the example service in that we supply a list of things,
> which include a link to where the details of those things can be found.
>  That link may or may not be a link relative to the initial list service, so
> the idea of just tacking on paths to the original URL as the current service
> element would have us do is not practical.
>

Axis2 wsdl2java tool assumes a service and binding otherwise it may
complicate the code generation. What you can do is to create a wsdl with a
service and import the correct wsdl to it. you can keep this wsdl only for
generation purposes.

>
> 2.  When the client makes a request to an unavailable resource (perhaps the
> details for that resource are no longer available), our service responds
> with an HTTP code (for example, 410 GONE), as well as an XML response.  It
> seems that the http transport layer complains before I get a chance to
> inspect the response - I'm assuming that dealing with this problem is a
> matter of working with the behavior of the HTTP transport interface?
>
> 3.  Outside of HTTP server errors - as I mentioned in the previous issue -
> we serve an XML response which details the error.  My understanding from the
> interface element of the WSDL, was that the client could expect to get up to
> 4 possibly different XML responses from the service - infault/outfault and
> input/output.  In testing the response handling of the client, whenever I
> invoke an error from the service, the client complains that it didn't get
> the response which it expected for the output (no error) response.  I'm
> assuming I don't have to wrap the response in something like a SOAP envelope
> to indicate the regular payload versus some fault payload, correct?
>

for a fault message it is supposed to send a soap fault. And the detail
element should have the element you describes in the wsdl. If you use axis2
it does this automatically.

thanks,
Amila.

>
> Any help input is greatly appreciated!
>
> thanks,
> -lev
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/