Mandatory WebMethod parameters

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. .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...
    5. 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...
  3. #2

    Default 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...
    > 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>

    Dino Chiesa [Microsoft] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139