Ask a Question related to ASP.NET Web Services, Design and Development.
-
Darren via .NET 247 #1
Mandatory WebMethod parameters
Hi,
I have WebService (C#) with one WebMethod that takes 4 parameters, as below:
<s:element minOccurs="0" maxOccurs="1" name="requestedBy" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="submissionDateTime" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="orderReference" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="currentState" type="s:string" />
My problem is that I would like every one of these arguments to be mandatory when being call by the client i.e.
<s:element minOccurs="1" maxOccurs="1" name="requestedBy" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="submissionDateTime" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="orderReference" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="currentState" type="s:string" />
If it is not clear what my problem is from this then please let me know and I will try to clarify.
Any suggestions would be a great help.
Thanks,
Darren
-----------------------
Posted by a user from .NET 247 ([url]http://www.dotnet247.com/[/url])
<Id>6ow0xmDJJE+41OOpB00uTg==</Id>
Darren via .NET 247 Guest
-
ftp mandatory authentication
How can you prompt for authentication to an ftp site on Windows 2003 server? I only see anonymous access... Also, I would like to be able to set... -
WebMethod and WSDL with optional parameters
Hi If i have a simple web service lik [WebMethodAttribute() public string DoIt(string Name, int Age return "" and i look at the WSDL i get... -
Carriage Return in WebMethod parameters
Hi! I have this problem. I am sending as a parameter for a webmethod a string containing '\r\n' sequences. For some reason, when I debug my... -
.exe is mandatory :-(
I just installed perl and I don't know what settings I fiddled with, but now on Windows Command Prompt I am unable to execute perl scripts with... -
How to use own classes as WebMethod-Parameters?
Is it possible to use self defined classes as parameters for a WebMethod? I thought of the following.... 1. Library-Project: "LibProj" Public... -
Dino Chiesa [Microsoft] #2
Re: Mandatory WebMethod parameters
Darren, you have a problem but you haven't said what the problem is.
Maybe I have an answer, but I'm not going to tell you. ???
Ok, I'm going to guess the problem. I am guessing that you are showing
WSDL snippets that have been generated, and they are not being generated the
way you want them to be.
Maybe you need to insert
[System.Xml.Serialization.XmlElementAttribute(IsNul lable=true)]
in front of each of the string params that you want to be "mandatory".
I think you will get minOccurs=1 maxOccurs=1 from this.
What this will do is tell the webservices infrastructure that if it receives
a message that does not include all those elements, it should reject it.
This doesn't assure you that all requests received by your app logic will be
valid (depending on your application, of course). The issue is that strings
can be null in C#. So a request that totally omits an element like
<requestedBy>...</requestedBy> will be rejected by the runtime, but
something like <requestedBy nil="true"/> will be accepted by the ASMX
runtime, and then forwwarded to your app. Your app still needs to validate
the input to verify that strings that should be non-null are in fact
non-null.
Such things as xsd restrictions don't always reproduce nicely in C# / CLR,
so you need to do the validation yourself.
-Dino
"Darren via .NET 247" <anonymous@dotnet247.com> wrote in message
news:O%23TUY1qMEHA.2644@TK2MSFTNGP11.phx.gbl...below:> Hi,
>
> I have WebService (C#) with one WebMethod that takes 4 parameters, astype="s:string" />>
> <s:element minOccurs="0" maxOccurs="1" name="requestedBy"type="s:dateTime" />> <s:element minOccurs="1" maxOccurs="1" name="submissionDateTime"type="s:string" />> <s:element minOccurs="0" maxOccurs="1" name="orderReference"type="s:string" />> <s:element minOccurs="0" maxOccurs="1" name="currentState"mandatory when being call by the client i.e.>
> My problem is that I would like every one of these arguments to betype="s:string" />>
> <s:element minOccurs="1" maxOccurs="1" name="requestedBy"type="s:dateTime" />> <s:element minOccurs="1" maxOccurs="1" name="submissionDateTime"type="s:string" />> <s:element minOccurs="1" maxOccurs="1" name="orderReference"type="s:string" />> <s:element minOccurs="1" maxOccurs="1" name="currentState"and I will try to clarify.>
> If it is not clear what my problem is from this then please let me know>
> Any suggestions would be a great help.
>
> Thanks,
>
> Darren
>
> -----------------------
> Posted by a user from .NET 247 ([url]http://www.dotnet247.com/[/url])
>
> <Id>6ow0xmDJJE+41OOpB00uTg==</Id>
Dino Chiesa [Microsoft] Guest



Reply With Quote

