Home Page › Forums › BizTalk 2004 – BizTalk 2010 › How to handle web service return value
- This topic has 5 replies, 1 voice, and was last updated 6 years, 11 months ago by
community-content.
-
AuthorPosts
-
-
May 26, 2006 at 8:38 AM #13716
I have a .net component which calls a web service and returns a string value.
I am using the component in the biztalk project in a expression shape. The expression is as follows –
TestWebService = new Test_WS_Call.TestClass();
RetVal = TestWebService .TestInvoke (); where
TestWebService is the component class object and
RetVal is the BixTalk variable of type System.String.I want to write the RetVal in a folder using File adapter.
My questions is –
1 – Can i write the RetVal directly to the file without using a message varible
2 – If not what i need, probably a schema, a message etc.If possible, please provide me step by step process.
Thanks.
-
May 27, 2006 at 10:14 AM #13717
Thanks, this is what I needed –
xmlDoc.Load(retValue);
myMessage = xmlDoc;I am using the following schema –
<sehema>
-root
-returnValue(This chield field element is of type xl:string)and i have defined a variable(RetVal) of type System.String and now the expression is –
TestWebService = new Test_WS_Call.TestClass();
RetVal = TestWebService .TestInvoke ();
myMessage = RetVal ( error here, could you please explain why?)
Thanks.
-
May 29, 2006 at 5:04 AM #13718
I have solved it, if anyone interested here’s the solution –
We need to use Message Assignment shape instead of Expression shape.
The expression for Message Assignment will be –
TestXML = new TestBPM_WS_Call.TestXMLClass();
RetVal = TestXML.TestInvoke (\”Test Input\”);
SendMessage = RetVal;Where –
RetVal is BizTalk variable of type System.String which holds the web Service return value.
SendMessage is BizTalk Message of type System.String.
We need to assign send port to SendMessage.
The web method is as follows –
[WebMethod]
public string GetGoodsMovement(string input)
{
return (\”Web service Response : \”+ input);
}If we drop the following xml file in receive port –
– <ns0:Root xmlns:ns0=\”http://TestBPM_WS_BA.ReceiveFileCommand\”>
<Descrip>Descrip_0</Descrip>
</ns0:Root>The output in the receive port will be –
<?xml version=\”1.0\” encoding=\”utf-8\” ?>
<string>Web service Response : Test Input</string>-
May 26, 2006 at 2:34 PM #13719
The normal way to call web services is to make a web reference, then use the send/receive shapes. I’ve never tried the direct .NET approach. Once you make a web reference, a schema is built for you (you can drill down under the web reference and view it).
Note that web services can return simple types or complex types.
A complex type is a .NET class or structure, and would be represented by a schema. A simple type would be a simple value such as a string, integer, etc…If the variable contains XML, you can do something like this:
1) Define a variable in Orch Viewer: xmlDoc of type System.Xml.XmlDocument
2) In an expression shape do this:
xmlDoc.Load(retValue);
myMessage = xmlDoc;In this case, you would have to have a schema to define a message called \”myMessage\”.
You could also write to a file directly using .Net classes, but this is probably not where you want to head.
One advantage of using Send/Recieve and Ports (for web services or flat files) is the Biztalk retry capabilities. If the web service is down, Biztalk will try it again. The SendPort has a retry interval and max retries parameter.
-
May 26, 2006 at 2:44 PM #13720
The normal way to call web services is to make a web reference, then use the send/receive shapes. I’ve never tried the direct .NET approach. Once you make a web reference, a schema is built for you (you can drill down under the web reference and view it).
Note that web services can return simple types or complex types.
A complex type is a .NET class or structure, and would be represented by a schema. A simple type would be a simple value such as a string, integer, etc…If the variable contains XML, you can do something like this:
1) Define a variable in Orch Viewer: xmlDoc of type System.Xml.XmlDocument
2) In an expression shape do this:
xmlDoc.Load(retValue);
myMessage = xmlDoc;In this case, you would have to have a schema to define a message called \”myMessage\”.
You could also write to a file directly using .Net classes, but this is probably not where you want to head.
One advantage of using Send/Recieve and Ports (for web services or flat files) is the Biztalk retry capabilities. If the web service is down, Biztalk will try it again. The SendPort has a retry interval and max retries parameter.
-
May 31, 2006 at 7:27 PM #13721
So why not call the webservice is the \”normal\” fashion, i.e. by making a web reference, and with Send/Receive shapes?
-
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.