You must Sign In to post a response.
  • Category: Webservices

    Index was outside the bounds of the array

    If i pass the below url I'm getting below error so kindly give solution

    http://localhost:54771/SMSWEBSERVICE/Service.asmx/SubmitBody?XmlFileData=<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <ns2:xmlData xmlns:ns2="http://vinodsingh.com"> <data><name>vinod</name></data> </ns2:xmlData> </S:Body></S:Envelope>




    Error Details

    System.IndexOutOfRangeException: Index was outside the bounds of the array.
    at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
    at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
    at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
    at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
  • #753831
    Hi,

    The problem is you are passing the xml data(envelop) as query string, this is not a valid format to send it across the query strings.


    If the envelop structure is common for all users then store it in a database are in a configuration file instead passing through query strings like :

    XmlFileData=<?xml version="1.0" ?>
    <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
    <ns2:xmlData xmlns:ns2="http://vinodsingh.com">
    <data>
    <name>@Name</name>
    </data>
    </ns2:xmlData>
    </S:Body>
    </S:Envelope>


    Then pass the value of <name> element as query strings, then the envelop and replace the name in it.

    Sample code like:

    strValue = Request.QueryString["XmlFileData"];

    strEnvelop.Replace("@Name",strValue);

    then do the need full.

    I hope it will helps you.

    Thanks,
    Murali.MD

  • #753835
    Hai G.Renganathan,
    This is quite common error which will occur when you try to access the elements with the indexes and the index is not available.
    If you can past your server side code where you are trying to access the values, we can help better.
    You need to check your server side code may be inside service that how this string(input) is getting parsed and then access the value and pass to the service to get the result.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


  • Sign In to post your comments