Hi All,
I need to send a message from .NET Web Service to a receive port in BizTalk orchestration. I'm using HTTP Adapter for this. I've used a HTTPWebRequest to send the message (after converting it in bytes) to a receive location (BTSHTTPReceive.dll which is a BizTalk ISAPI dll).
I've already configured the location and have specified the location in the Receive Port Location properties. But when I use the HAT tool to see the orchestration, I find that the orchestration hasn't executed even the first step, that is, the message hasn't reached the orchestration in the first place.
My code in the .NET Web Service looks like this:
Code:
[WebMethod]
public void getTemperature(string Temp)
{
double Result = 0;
Result = (Convert.ToDouble(Temp) * 1.8) + 32 ;
// indicates the location where the HTTP request is to be sent
string requestLocation = "http://localhost/HTTPReceiveLocation/BTSHTTPReceive.dll";
// create an XML object
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.PreserveWhitespace = true;
// create the root node (Temperature)
XmlNode tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Element, "Temperature", "");
xmlDocument.AppendChild(tempXmlNode);
// create the child element (Celsius)
tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Element, "Celsius", "");
tempXmlNode.InnerText = Temp;
xmlDocument.DocumentElement.AppendChild(tempXmlNode);
// create the child element (Farenheit)
tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Element, "Farenheit", "");
tempXmlNode.InnerText = Result.ToString();
xmlDocument.DocumentElement.AppendChild(tempXmlNode);
try
{
// create a web request and set the method of the request to POST
HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create(requestLocation);
request.Method = "POST";
// encode the data and store the byte representation in an array
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] requestData = encoding.GetBytes(xmlDocument.OuterXml);
// set the content type of the data being posted.
request.ContentType="application/x-www-form-urlencoded";
// set the content length of the string being posted
request.ContentLength = xmlDocument.OuterXml.Length;
// NetworkCredential cred = new NetworkCredential("administrator", "mbt123", "dscp01076");
// request.Credentials = cred;
// request.PreAuthenticate = true;
Stream requestStream = request.GetRequestStream();
requestStream.Write(requestData,0,requestData.Length);
// flush out the data to the underlying stream and close it
requestStream.Flush();
requestStream.Close();
}
catch (WebException wex)
{
}
}
Can somebody tell me where I'm wrong or am I missing something??
TIA
Debsoft