Hi Manish,

I am the one who wrote that article, the original was published at
http://wso2.org/library/3726. Nice to hear that you found it usefull. I have
answered your questions inline,

On Mon, Nov 17, 2008 at 10:11 PM, kat kat <[EMAIL PROTECTED]> wrote:

> I have actually followed Keith Chapman's article on webmonkey, which is
> here:
>
> http://www.webmonkey.com/tutorial/RESTful_Web_Services_with_Apache_Axis2
>
> If I go with instrumenting REST using WSDL 2.0 , then my basic question
> referring to the above article is how can we actually make a POST (add new
> student) on /services/studentService/students or rather POST any basic or
> Complex Type. From the wsdl, addStudent(Student student) is the service
> method that will get called and it needs an argument which should be an
> object of class Student.
> In truly RESTful way, this should be a form POST and the data is url
> encoded or rather sent in application/x-www-form-urlencoded content type. If
> I have to say use this service with REST client in Python, I will have to
> know about the Student object ,is it? I am missing something here, can you
> explain?
>
This actually depends on your your request message is defined. In the
example I've provided I have used a POJO as the input to the service method,
and when a POJO is used the default schema generated by Axis2 is as follows,

            <xs:element name="addStudent">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="student"
nillable="true" type="ax21:Student"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:complexType name="Student">
                <xs:sequence>
                    <xs:element minOccurs="0" name="age" type="xs:int"/>
                    <xs:element minOccurs="0" name="name"
nillable="true" type="xs:string"/>
                    <xs:element maxOccurs="unbounded" minOccurs="0"
name="subjects" nillable="true" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            </xs:element>

With a schema like this you cannot use the contentType
application/x-www-form-urlencoded (cause the server would not have enough
information to reconstruct the message). If you want to use
application/x-www-form-

urlencoded then you could do this by modifying your service method as
follows. addStudent(Sring name, int age, String [] subjects) . This would
generate a schema similar to,

            <xs:element name="addStudent">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="age" type="xs:int"/>
                        <xs:element minOccurs="0" name="name"
nillable="true" type="xs:string"/>
                        <xs:element maxOccurs="unbounded"
minOccurs="0" name="subjects" nillable="true" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>

This makes it possible to do what you are trying.

Please have a look at
http://www.keith-chapman.org/2008/09/restfull-mashup-with-wsdl-20-wso2.htmlas
well. There I have shown how you could play around with the WSO2
Mashup
Server [1] (It runs on top of Axis2 and allows you to write service using
JavaScript with ease) and experiment with stuff. You could use that to write
services and validate your ideas in a flash. Hope this helps.

Thanks,
Keith.

[1] http://wso2.org/projects/mashup

> On the other hand I could do POST, may not be ComplexType but of simple
> type if  I have my service class returning an AXIOM OMElement object as well
> as taking OMElement object as an argument to the action methods but WSDL 2.0
> way seems cleaner to me.
>
> Appreciate your feedback
>
> Thanks
> Manish
>



-- 
Keith Chapman
Senior Software Engineer
WSO2 Inc.
Oxygenating the Web Service Platform.
http://wso2.org/

blog: http://www.keith-chapman.org

Reply via email to