String xmlString = @"
<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/""
xmlns:nob=""http://www.nobre.com.br/"">
<soapenv:Header/>
<soapenv:Body>
<nob:Sync>
<nob:Contract>
<nob:Code>10</nob:Code>
<nob:LocalId>10</nob:LocalId>
</nob:Contract>
</nob:Sync>
</soapenv:Body>
</soapenv:Envelope>";
HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create("http://nobre.service.local/StateService.svc/BasicHttpBinding"); ASCIIEncoding encoding = new ASCIIEncoding(); byte[] bytesToWrite = encoding.GetBytes(xmlString); request.Method = "POST"; request.ContentLength = bytesToWrite.Length; request.Headers.Add("SOAPAction", "http://www.nobre.com.br/IContractService/Sync");
request.ContentType = "text/xml; charset=utf-8";
Stream newStream = request.GetRequestStream(); newStream.Write(bytesToWrite, 0, bytesToWrite.Length); newStream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string responseFromServer = reader.ReadToEnd();
↧
SERVICE BUS + WCF + WEB REQUEST
↧