Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. SoapException was unhandled by user code

SoapException was unhandled by user code

Scheduled Pinned Locked Moved ASP.NET
csharpvisual-studioxmlasp-netdotnet
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NewToAspDotNet
    wrote on last edited by
    #1

    Dear friends, i wrote a asp.net webservice using vs 2008 .net framework 3.5. this service runs over https. it gets the parameters from the client and sends this to another application and then the answer from that application back to the client. It works sometimes fine, bud sometimes im getting this exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Net.WebException: The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF at System.Net.HttpWebRequest.GetResponse() at WebService2.Service1.HttpSOAPRequest(String xmlfile, String proxy) in C:\Documents and Settings\BB\My Documents\Visual Studio 2008\Projects\WebService2\WebService2\Service1.asmx.cs:line 44 at WebService2.Service1.CardWithPerson(String persId, String projectId, String username, String pw) in C:\Documents and Settings\BB\My Documents\Visual Studio 2008\Projects\WebService2\WebService2\Service1.asmx.cs:line 82 --- End of inner exception stack trace --- Here is some code of the webservice:

    [WebMethod]
    public String CardWithPerson(string persId, string projectId, string username, string pw)
    {
    xmlfile = "<?xml version=\"1.0\" encoding=\"utf-8\" ?> "
    + "<soap:Envelope xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\\">"
    +"soap:Body"
    +"<PS_CardsWithPersonReq xmlns=\"http://tempuri.org\">"
    +"<WebAuthenticate>"
    +" <WebUser>"+username+"</WebUser>"
    +" <WebPass>"+pw+"</WebPass>"
    +" <WebIp>"+Context.Request.UserHostAddress+"</WebIp>"
    +" <WebMd>0123456789ABCDEF0123</WebMd>"
    +" </WebAuthenticate>"
    +"<PersNr>"+persId+"</PersNr>"
    +"<Lang>E</Lang>"
    +"<ProjCode>"+projectId+"</ProjCode>"
    +"</PS_CardsWithPersonReq>"
    +"</soap:Body>"
    +"</soap:Envelope>";
    r = HttpSOAPRequest(xmlfile, null);
    result = r.ReadToEnd();
    return result;
    }

    StreamReader HttpSOAPRequest(String xmlfile, string proxy)
    {
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(xmlfile);

            HttpWebRequest req = (HttpWebRequest)WebRequest.Cr
    
    L G N 3 Replies Last reply
    0
    • N NewToAspDotNet

      Dear friends, i wrote a asp.net webservice using vs 2008 .net framework 3.5. this service runs over https. it gets the parameters from the client and sends this to another application and then the answer from that application back to the client. It works sometimes fine, bud sometimes im getting this exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Net.WebException: The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF at System.Net.HttpWebRequest.GetResponse() at WebService2.Service1.HttpSOAPRequest(String xmlfile, String proxy) in C:\Documents and Settings\BB\My Documents\Visual Studio 2008\Projects\WebService2\WebService2\Service1.asmx.cs:line 44 at WebService2.Service1.CardWithPerson(String persId, String projectId, String username, String pw) in C:\Documents and Settings\BB\My Documents\Visual Studio 2008\Projects\WebService2\WebService2\Service1.asmx.cs:line 82 --- End of inner exception stack trace --- Here is some code of the webservice:

      [WebMethod]
      public String CardWithPerson(string persId, string projectId, string username, string pw)
      {
      xmlfile = "<?xml version=\"1.0\" encoding=\"utf-8\" ?> "
      + "<soap:Envelope xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\\">"
      +"soap:Body"
      +"<PS_CardsWithPersonReq xmlns=\"http://tempuri.org\">"
      +"<WebAuthenticate>"
      +" <WebUser>"+username+"</WebUser>"
      +" <WebPass>"+pw+"</WebPass>"
      +" <WebIp>"+Context.Request.UserHostAddress+"</WebIp>"
      +" <WebMd>0123456789ABCDEF0123</WebMd>"
      +" </WebAuthenticate>"
      +"<PersNr>"+persId+"</PersNr>"
      +"<Lang>E</Lang>"
      +"<ProjCode>"+projectId+"</ProjCode>"
      +"</PS_CardsWithPersonReq>"
      +"</soap:Body>"
      +"</soap:Envelope>";
      r = HttpSOAPRequest(xmlfile, null);
      result = r.ReadToEnd();
      return result;
      }

      StreamReader HttpSOAPRequest(String xmlfile, string proxy)
      {
      XmlDocument doc = new XmlDocument();
      doc.LoadXml(xmlfile);

              HttpWebRequest req = (HttpWebRequest)WebRequest.Cr
      
      L Offline
      L Offline
      Leonardo Muzzi
      wrote on last edited by
      #2

      Just guessing, but the problem might occur when some of your variables (username, pwd, persID, projectId, ....) have invalid chars, like xml schema chars. Seems your webservice is accessing other webservice, right? If you're using Visual Studio, you can just reference the other webservice (Right click on project -> Add Web Reference). VS will automatically create a new class encapsulating the webservice, so you just call for WebServiceClass.PS_CardsWithPersonReq method with the parameters. You might need WS Secutity to authenticate.

      Regards, Leonardo Muzzi

      1 Reply Last reply
      0
      • N NewToAspDotNet

        Dear friends, i wrote a asp.net webservice using vs 2008 .net framework 3.5. this service runs over https. it gets the parameters from the client and sends this to another application and then the answer from that application back to the client. It works sometimes fine, bud sometimes im getting this exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Net.WebException: The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF at System.Net.HttpWebRequest.GetResponse() at WebService2.Service1.HttpSOAPRequest(String xmlfile, String proxy) in C:\Documents and Settings\BB\My Documents\Visual Studio 2008\Projects\WebService2\WebService2\Service1.asmx.cs:line 44 at WebService2.Service1.CardWithPerson(String persId, String projectId, String username, String pw) in C:\Documents and Settings\BB\My Documents\Visual Studio 2008\Projects\WebService2\WebService2\Service1.asmx.cs:line 82 --- End of inner exception stack trace --- Here is some code of the webservice:

        [WebMethod]
        public String CardWithPerson(string persId, string projectId, string username, string pw)
        {
        xmlfile = "<?xml version=\"1.0\" encoding=\"utf-8\" ?> "
        + "<soap:Envelope xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\\">"
        +"soap:Body"
        +"<PS_CardsWithPersonReq xmlns=\"http://tempuri.org\">"
        +"<WebAuthenticate>"
        +" <WebUser>"+username+"</WebUser>"
        +" <WebPass>"+pw+"</WebPass>"
        +" <WebIp>"+Context.Request.UserHostAddress+"</WebIp>"
        +" <WebMd>0123456789ABCDEF0123</WebMd>"
        +" </WebAuthenticate>"
        +"<PersNr>"+persId+"</PersNr>"
        +"<Lang>E</Lang>"
        +"<ProjCode>"+projectId+"</ProjCode>"
        +"</PS_CardsWithPersonReq>"
        +"</soap:Body>"
        +"</soap:Envelope>";
        r = HttpSOAPRequest(xmlfile, null);
        result = r.ReadToEnd();
        return result;
        }

        StreamReader HttpSOAPRequest(String xmlfile, string proxy)
        {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(xmlfile);

                HttpWebRequest req = (HttpWebRequest)WebRequest.Cr
        
        G Offline
        G Offline
        Gayani Devapriya
        wrote on last edited by
        #3

        Hi, Can you please highlight the line numbers indicated in the error message or can you paste the code with the line numbers. Gayani

        N 1 Reply Last reply
        0
        • G Gayani Devapriya

          Hi, Can you please highlight the line numbers indicated in the error message or can you paste the code with the line numbers. Gayani

          N Offline
          N Offline
          NewToAspDotNet
          wrote on last edited by
          #4

          Hi Gayani Devapriya, Thanks for your response. This is the line:

          WebResponse resp = req.GetResponse();

          You can see it In the methode: StreamReader HttpSOAPRequest(String xmlfile, string proxy)

          1 Reply Last reply
          0
          • N NewToAspDotNet

            Dear friends, i wrote a asp.net webservice using vs 2008 .net framework 3.5. this service runs over https. it gets the parameters from the client and sends this to another application and then the answer from that application back to the client. It works sometimes fine, bud sometimes im getting this exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Net.WebException: The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF at System.Net.HttpWebRequest.GetResponse() at WebService2.Service1.HttpSOAPRequest(String xmlfile, String proxy) in C:\Documents and Settings\BB\My Documents\Visual Studio 2008\Projects\WebService2\WebService2\Service1.asmx.cs:line 44 at WebService2.Service1.CardWithPerson(String persId, String projectId, String username, String pw) in C:\Documents and Settings\BB\My Documents\Visual Studio 2008\Projects\WebService2\WebService2\Service1.asmx.cs:line 82 --- End of inner exception stack trace --- Here is some code of the webservice:

            [WebMethod]
            public String CardWithPerson(string persId, string projectId, string username, string pw)
            {
            xmlfile = "<?xml version=\"1.0\" encoding=\"utf-8\" ?> "
            + "<soap:Envelope xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\\">"
            +"soap:Body"
            +"<PS_CardsWithPersonReq xmlns=\"http://tempuri.org\">"
            +"<WebAuthenticate>"
            +" <WebUser>"+username+"</WebUser>"
            +" <WebPass>"+pw+"</WebPass>"
            +" <WebIp>"+Context.Request.UserHostAddress+"</WebIp>"
            +" <WebMd>0123456789ABCDEF0123</WebMd>"
            +" </WebAuthenticate>"
            +"<PersNr>"+persId+"</PersNr>"
            +"<Lang>E</Lang>"
            +"<ProjCode>"+projectId+"</ProjCode>"
            +"</PS_CardsWithPersonReq>"
            +"</soap:Body>"
            +"</soap:Envelope>";
            r = HttpSOAPRequest(xmlfile, null);
            result = r.ReadToEnd();
            return result;
            }

            StreamReader HttpSOAPRequest(String xmlfile, string proxy)
            {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xmlfile);

                    HttpWebRequest req = (HttpWebRequest)WebRequest.Cr
            
            N Offline
            N Offline
            NewToAspDotNet
            wrote on last edited by
            #5

            Hi, The problem is solved by adding req.KeepAlive = false; ofter creating the request :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups