Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Web Service SimpleType restrictions?  RSS feed

 
Nauman Hasan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am experimenting with a simple web service and trying to restrict the length of data that gets passed in. The platform is Windows XP / WebSphere 5.1.

My understanding is that it is possible to specify the lengths (minLength, maxLength) in the WSDL such that the runtime will cause a soap message that if the message does not comply to the specification.

So for example
Type:
<simpleType name="OneToTenType">
<restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="10"/>
</restriction>
</simpleType>

Element:
<element name="setFirstName">
<complexType>
<sequence>
<element name="firstName" nillable="true" type="intf neToTenType"/>
</sequence>
</complexType>


Operation:
<wsdl:message name="setFirstNameResponse">

<wsdl art element="impl:setFirstNameResponse" name="parameters"/>

</wsdl:message>


However, if I send a message of length larger than 10 it is accepted and passed to the application code. Is this the expected behaviour of is there something wrong with my setup?

Thank you for your help
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've not used Websphere, so I can't comment. That said, your simpleType declaration looks odd. Why have you used the 'xsd:' prefix for the minLength and maxLength elements, but not for the simpleType itself? I'd wager you want something more like this:



(That validates with XMLSpy 2005, so I'm pretty sure it's legal XMLSchema. Whether or not Websphere understands it is another matter, however).

Perhaps in your current simpleType, the minLength and maxLength elements are being ignored, as they're in the wrong namespace. What namespace is associated with 'xsd' prefix in that schema?

Dunno if any of that will help, but there ya go...


-Tim
 
Nauman Hasan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Tim for your help it is much appreciated. I tried your suggestion but it still does not appear that the wsdl validates the simpleType. Although it is good to know that I am not trying to do something unsupported by wsdl. I have attached my modified wsdl perhaps looking at it will shed some light into this problem.

You may notice that the <xsd:simpleType name="OneToTenType"> has the name unqualified... this is because if I put the xsd in front the wsdl editor I am using refuses the validate the wsdl...



[ July 28, 2005: Message edited by: N Hasan ]

[ July 28, 2005: Message edited by: N Hasan ]
[ July 28, 2005: Message edited by: N Hasan ]
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I can't help then. One odd thing, is that you've got two namespace prefixes assigned to the XML schema namespace, i.e., "" (empty/default prefix) and 'xsd'. I would be surprised if that was confusing the the Websphere toolkit, but maybe it is. You've also done similarly with the namespace "http://net" - you've used prefixes 'impl' and 'intf'. I'd remove this if I were you and try again. I'm thinking of something like the following, but I've just hacked it around - I'm not going to try and use it myself.

If you can't get it to work, I'd try the IBM forums, or use your IBM support contract.




-Tim
[ August 02, 2005: Message edited by: Tim West ]
 
Nauman Hasan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim, I will try it out and post back as to what I have found.

Regards,
Nauman
 
Nauman Hasan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, no joy. It still does not work. Just as a general question I was looking at specifications for WSDL and it does not explicitly say that these type of checks should work (they refer to the xsd documents which would seem to imply that all schema syntax should work). Do they work in other products (string lengths checks in wsdl)? Is it common that parts of the wsdl specifications are not implemented by different products?

Thanks,
Nauman
 
Tim West
Ranch Hand
Posts: 539
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've had them work in Weblogic 7, Weblogic 8.1 and Axis. I've not tried with Websphere.

You're right though - and that's one of my big issues with XML Schema. XML Schema is vastly overcomplicated for its purpose with Web services, this might have been (this is a guess) the reason for SOAP encoding, and I know that OASIS is working on "Relax NG" - a competitor to XML Schema, which might also be because of complications. That's all guessing, though.

Anyway, because it's so complicated, no-one implements all of it. They implement bits, and don't (always) document which parts are left out. So, you hit this sort of problem. In a similar vein, Weblogic 7 didn't support xsd:choice (but *did* tell you so, in an error message when generating WSDL - Java bindings). It's a pretty poor situation...which would be alleviated by SOAP encoding, except it'll never be used now (it's ruled out in the Basic Profile).

Did you try the IBM forums? That'd still be my best bet.


-Tim
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should add - I just looked at the Relax NG compact syntax tutorial and it looks like a joke! Since it isn't XML-based, it isn't exactly prime material to use in place of XML Schema in Web services. Still, stranger things have happened.


-Tim
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!