The very first web service that we usually create in any programming language, turned out to be not-so-simple in BizTalk. Here's classic example:
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
And the problem is two-fold in BizTalk Server (which strictly adhering to message schemas):
1. If BizTalk Server is supposed to consume such web service, it is fairly known issue that we'll need to generate an "empty" web message as input parameter to be passed to the method being called. Many sites have cited the resolution, so I'm not going to describe this case anymore.
Error message when you try to build a project in BizTalk Server 2006
2. The more problematic case (for me) is when we're supposed to expose such service using BizTalk Server. Orchestration requires a trigger message to kick-off the orchestration. But, if i don't have input parameter, how do I tell the web service published orchestration to start? The orchestration does expecting a multipart message with no message part (it's a web message). Following standard procedure of publishing web service based on orchestration with request/response port, the signature of the web methods are created just fine.
And my code in client application look like this:
textBox3.Text = test.HelloWorld();
where "test" is the web reference to the web service above. Notice that there is no input parameter here. But alas, I got this error:
"Internal SOAP Processing Failure"
Great! No event log entry. No message tracked in BizTalk Admin Console. IIS log shows error 500. Scratching my head...
After some readings, found out that it could be due to the similar issue of no#1 above. Which means... I'll need an input parameter!!! :o
http://geekswithblogs.net/cyoung/articles/4634.aspx
http://blogs.msdn.com/richardbpi/archive/2006/10/23/advanced-biztalk-2006-web-services-part-ii.aspx
http://www.jonfancey.com/default.aspx (somehow i can't find back the article that i've just read)
So, workaround is, instead of having a multipart message with no message part as incoming message, i created a normal multipart message with 1 bodypart. Any XML schema based body part. Sure enough, the webservice that was generated by the web service publishing wizard required an input parameter for the method. So, I have to open up the web service solution, removed the input parameter and add defaulting invokeParam code a bit. Rebuild, and it works. It's as simple as that. Here's the part that i've changed (on the asmx code behind. Code has been simplified.):
public string HelloWorld()
{
...
// Parameter information
USoup.WS101.XsdTypesBody.EmptyInputParam EmptyBody = new USoup.WS101.XsdTypesBody.EmptyInputParam();
EmptyBody.SomeValue = System.DateTime.Now.ToLongTimeString();
...
}
Note: "USoup.WS101.XsdTypesBody.EmptyInputParam" is the multipart message that has bodypart. "SomeValue" is just a node in the message.