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);
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
<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"></theBinData>
<theBinLength>154695654</theBinLength>
</content>
</document>
<eventNotification>
<claimNumber>0001500010</claimNumber>
<vehicleNumber>001</vehicleNumber>
</eventNotification>
</HandleVehicleRepairEventNotificationRequest>
</soap:Body>
</soap:Envelope>