开发者

WADL: complex type from external xsd

开发者 https://www.devze.com 2023-01-30 09:17 出处:网络
I need to test authentication procedure using the wadl file below: <application xmlns=\"http://research.sun.com/wadl/2006/10\"

I need to test authentication procedure using the wadl file below:

<application xmlns="http://research.sun.com/wadl/2006/10" 
         xmlns:sis="http://sis.thecompany.com/" >
<grammars>
    <include href="http://localhost/wadl/sis.xsd"/>
</grammars>
<resources base="http://192.168.10.139">
    <resource path="/user/sign_in">
        <method name="POST" id="Authentication">
            <request>
                <param name="user" type="sis:user" required="true"/>
                <representation mediaType="application/xml" element="sis:user"/>
            </request>
            <response status="201">
                <representation mediaType="application/xml"/>
                <fault status="401" />
            </response>
        </method>
    </resource>
</resources>

After importing this file to the soapUI Pro I got no action by clicking to Request. The reason is that soapUI Pro does not see element "sis:user" as it present in xsdand thought that it is just some single element with undefined type. Can you advice wthat's wrong wit开发者_Go百科h the wadl file?

Below is the sis.xsd schema used:

<?xml version="1.0" encoding="utf-8"?> <xs:schema id="SIS" targetNamespace="http://sis.thecompany.com/" elementFormDefault="qualified" xmlns="http://sis.thecompany.com/" xmlns:mstns="http://sis.thecompany.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"> <xs:element name="application"> <xs:complexType> <xs:all> <xs:element name="user" minOccurs="0"> <xs:xs:complexType> <xs:all minOccurs="1"> <xs:element name="login" type="xs:string" /> <xs:element name="password" type="xs:string" /> </xs:all> </xs:complexType> </xs:element> </xs:all> </xs:complexType> </xs:element> </xs:schema>

And the next question. If soapUI Pro will correct parse complexType element user from xsd - POST data from soapUI Pro will be the next:

<sis:user><sis:login>admin</sis:login><sis:password>admin!</sis:password></sis:user>

But this will be rejected by server due to additional prefix 'sis:'. Server support only the next format

<user><login>admin</login><password>admin!</password></user>

Please advice.


The best advice I can give is to stop using WADL. Find a decent HTTP library and XML parser in whatever language you are using and create your XML file and POST it. It should take just a few lines of code to achieve this.

By using WADL and xsd the way you are doing, all you are achieving is creating tight coupling between the client and the server. This will negate the majority of the benefits a REST system is supposed to bring. You might as well stick with SOAP, at least the tooling is mature.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号