views:

126

answers:

1

I am calling a web service (written in Java) in my web app. I use the WSDL to generate proxy classes using the wsdl.exe command line tool.

Everything is working fine.

However, I have found out that the web service is not doing any data validation at all when they receive a request from my app. Hence, if I happen to send one minute piece of data that isn't exactly what they want, I receive a general fault error in return, with no specifics at all of what the incorrect (if any) piece of data is.

So, before I make the request, I'd like to validate my request against the schema they have provided. Is this possible, and if so, how do I go about this?

Thanks in advance

A: 

The proxy built from the wsdl already enforces whatever schema was provided unless, of course, the call takes a string parameter where you are supposed to pass xml. That would be bad design but if that's what you have to do, you can. Just use the XmlDocument object or the XmlReader to validate the XML.

Tom Cabanski
My request allows me to send objects created from generating the proxy, so I'm not creating the XML by hand.This is a sample of a call I make - ContextType tx1 = loyal.GetPoints(tx, obj.Profile.AccountNumber, DateTime.Now, true, consumerName, out pointType, out responseCode);I don't think recreating the XML by hand would be helpful to ensuring I'm sending the correct items?Thanks for your assistance so far
TheGeekYouNeed
Ok. So that means what you are sending is already validated against the schema provided by the server (i.e. the WSDL). Therefore, the issue is that the WSDL does not properly express the requirement. About the best thing you could do in this case is to do some extra checking in your code to enforce the additional requirements you discover that are not expressed in the WSDL.
Tom Cabanski
Well, it isn't being validated against the schema.... I think that is why I was asking how to do it. (please don't read that wrong, this is a new area of C# i'm venturing into, and I really don't know all that is going on yet but have to get things done on a very short deadline)For instance, I have an Address object created by the WSDL. One of its properties is State, which is supposed to only be a 2 character data item. I can make the call to the web service with bad data in the state field. The web service returns me a "general fault" error in this case, however.
TheGeekYouNeed