Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 ?
XML
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;

    }
Posted
Updated 28-Mar-14 23:03pm
v3

1 solution

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//
 
Share this answer
 

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