Click here to Skip to main content
13,193,590 members (48,641 online)
Rate this:
 
Please Sign up or sign in to vote.
I got a XML source, is a php url like "http://www.abc.com/status.php

I need to submit xml to this url by post method,
for example:
<?xml version="1.0" encoding="UTF-8" ?>
<request>
<hmcreflist>
<hmcref>W1009430</hmcref>
</hmcreflist>
</request>



then , it will return XML back
for example:
<?xml version="1.0" encoding="UTF-8" ?>
<QBOOKINGSTATUS>
<XML_RESULT>
<HMCREFLIST>
<HMCREF>W1009430</HMCREF>
<REFNO>A12346</REFNO>
<STATUSCODE>OR</STATUSCODE>
<STATUSDESC>On Request</STATUSDESC>
<CANCELDESC />
</HMCREFLIST>
</XML_RESULT>
</QBOOKINGSTATUS>



How can I design a ssis package to do this action?
Posted 12-Aug-12 4:36am
Updated 12-Aug-12 4:45am
v3

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Use Script Task and do post as :
 
        public static string POST(string postData, string url, string referer, string cookie)
        {
            string retValue = string.Empty;
            try
            {
                byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
                request.Method = "POST";
                request.KeepAlive = true;
                request.AllowAutoRedirect = false;
                request.Accept = "*/*";
                request.ContentType = "text/xml";
                if (!string.IsNullOrEmpty(cookie))
                    request.Headers.Add(HttpRequestHeader.Cookie, cookie);
 
                if (!string.IsNullOrEmpty(referer))
                    request.Referer = referer;
                request.ContentLength = byteArray.Length;
                request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
                //   request.Proxy = null;
                Stream dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();
                try
                {
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    Stream dataResponseStream = response.GetResponseStream();
                    StreamReader SR = new StreamReader(dataResponseStream, Encoding.UTF8);
                    retValue = SR.ReadToEnd();
                    response.Close();
                    dataStream.Close();
                    SR.Close();
                    request.Abort();
                }
                catch
                {
                }
            }
            catch
            {
            }
            return retValue;
        }


how to call the above method :
string postdata = oReqDoc.InnerXml; //oReqDoc is the XMLDoc you need to post. If you have xml as in text form simply sent it.
string url ="http://www.abc.com/status.php php";
pass referrer and cookie as ""
now call POST as :
string strReponse = POST(postdata, url, "", "");

now you can inspect if you have got the right output xml.

you can try the following snippet too to convert string to xml:

XmlDocument doc = new XmlDocument{ XmlResolver = null };
            doc.LoadXml(strReponse);
            XmlNode newNode = doc.DocumentElement; 


Note: You may need following namespaces:
using System.Net;
using System.IO;
using System.Web;
using System.Xml;



Thanks,

Kuthuparakkal
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web02 | 2.8.171018.2 | Last Updated 19 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100