如何在Asp.Net中调用或调用Soap Xml Web服务 [英] How Do I Invoke Or Call Soap Xml Web Service In Asp.Net
本文介绍了如何在Asp.Net中调用或调用Soap Xml Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,这是我的第一次,所以我需要您的帮助,这是我的xml肥皂链接
[ ^ ]
这是我的c#代码,我在做错了?
Hi this is my first time so i need your help here is my Link of xml soap
[^]
here is my c# code kindly where i am doing wrong ?
public string SoapPatientMedication()
{ string resultXml;
WebRequest wbrqst = WebRequest.Create("http://preproduction.newcropaccounts.com/v7/WebServices/Patient.asmx");
HttpWebRequest httpreq = (HttpWebRequest)wbrqst;
httpreq.Method = "POST";
httpreq.ContentType = "text/xml charset=utf-8";
httpreq.Headers.Add("SOAPAction","https://secure.newcropaccounts.com/V7/webservices/GetPatientFullMedicationHistory");
httpreq.ProtocolVersion = HttpVersion.Version11;
httpreq.Credentials = CredentialCache.DefaultCredentials;
Stream requestStream = httpreq.GetRequestStream();
StreamWriter streamWriter = new StreamWriter(requestStream, Encoding.ASCII);
StringBuilder sb = new StringBuilder();
sb.Append("<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>");
sb.Append("<soap:Body>");
sb.Append("<GetPatientFullMedicationHistory xmlns='https://secure.newcropaccounts.com/V7/webservices'>");
sb.Append("<credentials>");
sb.Append("<PartnerName>demo</PartnerName>");
sb.Append("<Name>demo</Name>");
sb.Append("<Password>demo</Password>");
sb.Append("</credentials>");
sb.Append("<accountRequest>");
sb.Append("<AccountId>demo</AccountId>");
sb.Append("<SiteId>demo</SiteId>");
sb.Append("</accountRequest>");
sb.Append("<patientRequest>");
sb.Append("<PatientId>16</PatientId>");
sb.Append("</patientRequest>");
sb.Append("<prescriptionHistoryRequest>");
sb.Append(" <StartHistory>2004-01-01T00:00:00.000</StartHistory>");
sb.Append("<EndHistory>2012-01-01T00:00:00.000</EndHistory>");
sb.Append("<PrescriptionStatus>C</PrescriptionStatus>");
sb.Append("<PrescriptionSubStatus>%</PrescriptionSubStatus>");
sb.Append("<PrescriptionArchiveStatus>N</PrescriptionArchiveStatus>");
sb.Append("</prescriptionHistoryRequest>");
sb.Append("<patientInformationRequester>");
sb.Append("<UserType>demo</UserType>");
sb.Append("<UserId>demo</UserId>");
sb.Append("</patientInformationRequester>");
sb.Append("</GetPatientFullMedicationHistory>");
sb.Append("</soap:Body>");
sb.Append("</soap:Envelope>");
streamWriter.Write(sb.ToString());
streamWriter.Close();
HttpWebResponse wr = (HttpWebResponse)httpreq.GetResponse();
StreamReader srd = new StreamReader(wr.GetResponseStream());
resultXml = srd.ReadToEnd();
return resultXml;
}
推荐答案
我知道我做错了什么
错了一个
WebRequest wbrqst = WebRequest.Create(http://preproduction.newcropaccounts.com/v7/WebServices/Patient.asmx);
更正一个
WebRequest wbrqst = WebRequest.Create(https://preproduction.newcropaccounts.com/v7/WebServices/Patient.asmx);
the网页请求是https //而不是http //
i got it where i was doing wrong
wrong one
WebRequest wbrqst = WebRequest.Create("http://preproduction.newcropaccounts.com/v7/WebServices/Patient.asmx");
correct one
WebRequest wbrqst = WebRequest.Create("https://preproduction.newcropaccounts.com/v7/WebServices/Patient.asmx");
the web request is https// rather then http//
这篇关于如何在Asp.Net中调用或调用Soap Xml Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文