Click here to Skip to main content
15,891,650 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

Iam using a web service to post a xml file. but when i getresponse from the service this error is occuring.

My code is

HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(RequestURL);


string file = "F:\\datas.xml";

FileInfo fi = new FileInfo(file);
int fileLength = (int)fi.Length;


FileStream rdr = new FileStream(file, FileMode.Open);
System.Net.ServicePointManager.Expect100Continue = false;
//WebReq.Host = "https://servicestest.westfieldgrp.com";
WebReq.Method = "POST";
//WebReq.ContentType = "application/xml";
WebReq.ContentType = "application/json";
WebReq.Accept = "application/soap+xml,multipart/related,text/*";
WebReq.UserAgent = "IBM WebServices/1.0";
WebReq.Headers.Add(HttpRequestHeader.CacheControl, "no-cache");
WebReq.Headers.Add(HttpRequestHeader.KeepAlive, "true");
WebReq.Headers.Add(HttpRequestHeader.Pragma, "no-cache");
WebReq.ContentType = "application/xop+xml; charset=UTF-8; type=\"text/xml\"";
//WebReq.ContentType = "multipart/related; boundary=\"MIMEBoundary_a87c21b54731bfc0a46cf595e2394bf5fd0610949d26198d\"; type=\"application/xop+xml\"; start=\"<0.b87c21b54731bfc0a46cf595e2394bf5fd0610949d26198d@apache.org>\"; start-info=\"text/xml\"";
WebReq.UnsafeAuthenticatedConnectionSharing=true;
WebReq.Headers.Add("SOAPAction", action);


C#
byte[] requestBytes = new byte[fileLength];

                int bytesRead = 0;
                WebReq.ContentLength = requestBytes.Length;
                using (Stream requestStream = WebReq.GetRequestStream())
                {
                    while ((bytesRead = rdr.Read(requestBytes, 0, requestBytes.Length)) != 0)
                    {
                        requestStream.Write(requestBytes, 0, bytesRead);
                        requestStream.Close();
                    }
                }


string x = WebReq.GetResponse().GetResponseStream().ToString(); --> Here error occuring



This is my xml file
XML
<soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:body>
    <handlevehiclerepaireventnotificationrequest xmlns="http://www.westfieldgrp.com/enterprisemodel/wx">
      <document xsi:type="ElectronicDocument">
        <documentmetadata>
          <documentname>Cash Out Estimate Image</documentname>
        </documentmetadata>
        <content>
          <thecontenttype>application/pdf</thecontenttype>
          <thebindata>
Here i have a very bigger string<pre lang="xml">&lt;/theBinData&gt;



<theBinLength>154695654</theBinLength>
</content>
</document>
<eventNotification>
<claimNumber>0001500010</claimNumber>
<vehicleNumber>001</vehicleNumber>
</eventNotification>
</HandleVehicleRepairEventNotificationRequest>
</soap:Body>
</soap:Envelope>
Posted
Updated 25-Nov-13 23:05pm
v2
Comments
Bernhard Hiller 26-Nov-13 5:39am    
Come on, the exception occured on the SERVER, not on the client. Consequently, we must see SERVER code. True, the data sent from the client to the server are important - but what does the server do, how does the function called by RequestURL look like?
[no name] 26-Nov-13 22:49pm    
have a look http://social.msdn.microsoft.com/Forums/en-US/332193ad-6275-4d26-ad02-d454d5c2bc01/the-remote-server-returned-an-error-500-internal-server-error?forum=biztalkgeneral

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900