http://www.developer.com/net/net/article.php/3582011/BizTalk-2004-Adapter-Alternatives-for-Handling-Web-Services.htm
Although BizTalk 2004 is generations ahead of its predecessor in handling Web services, it still presents some limitations when you begin to invoke a Web service. For example, BizTalk does not handle Web service ArrayList return types and other complicated XML message schemes. Luckily, BizTalk 2004 Orchestrations include support for the .NET Framework. With .NET Framework support for Web services, you can handle an odd Web service, such as an ArrayList, without resorting to building your own adapter. Using a simple example, this article shows how to integrate .NET Framework Web services support into a BizTalk 2004 Orchestration. Before proceeding, a couple clarifications will put the example in the right context. First, the underlying technology matters. Web service support and conventions can vary depending on the environment hosting the Web service. For example, some platforms don't distinguish between an integer and floating point value; they simply support a Numeric Datatype. Second, although the example utilizes all Microsoft technologies, you can apply the same ideas to integrate BizTalk with another vendor's technology. The example includes the following components: Now, you can turn your attention to the example's Web service component. The Web service, TestXML, has implemented a single function (TestInvoke) that accepts a few parameters and returns a .NET Framework ArrayList. The following is the body of the TestInvoke function: As stated earlier, the TestXML is hosted in IIS. The IIS Web site hosting TestXML has been set up to use SSL and configured with IIS Basic Security. Although configuring an IIS site to use SSL and Basic Security is beyond the scope of this article, the key changes to make in IIS are summarized below. First, to implement Basic Security in IIS, make sure Basic Authentication is switched on and Anonymous security is turned off (see Figure 1). Figure 1: Implement Basic Security in IIS Implementing SSL is a little more complicated. The example uses selfssl.exe, a command-line utility that ships with the IIS Resource Kit (see Figure 2). Figure 2: SelfSSL.exe Command-Line Utility SelfSSL.exe will create a certificate and set up SSL on your Web site. Before invoking the Web service, quickly review of the Orchestration (see Figure 3). Figure 3: The Orchestration The "Call WS" expression icon invokes the Web service. As stated earlier, Web service handling is wrapped in an assembly. The assembly has been included in the solution along with the Orchestration. Because you are loading the assembly in the GAC, it has been strongly named. When you create a Web reference to the Web service, Visual Studio reads the service's WSDL code and creates the appropriate classes for you. The following code from the assembly invokes the Web service: As you can see, some of the code is a straightforward Web service invocation. Some of the other code dealing with authentication and secure communication requires some explanation. Minimal Web service best practices dictate that a Web service support some type of authentication and secure communication. In this example, authentication is done via IIS Basic Security and secure communication is implemented using SSL. So, to invoke the Web service, you must supply the proper credentials (authentication) and perform some actions to accept a certificate. When use a Web browser to communicate with a SSL site, you must accept a certificate to secure the connection with the site. In a BizTalk Orchestration, there is no user to accept the certificate. So, you must programmatically accept the certificate. The following line of code accepts all X.509 Certificates: TestWSTrustCertificatePolicy implements the ICertificatePolicy interface. The example accepts all X.509 certificates. In your own ICertificatePolicy implementation, you can filter for particular certificates by using the X509Certificate parameter. Next, you must authenticate. The following code performs the authentication: As you can see, the code supplies a login and password, and directs the credentials for use with Basic Security. Before applying the ideas in the previous sections to your own implementation, you must consider a few things: As you may have noticed in the example code snippets, sensitive information such as a username and password are embedded in the code. Depending on your security requirements, you may want to secure this information. If you were using the BizTalk HTTP adapter, you could've used single sign-on (SSO) to store credentials. SSO may still be an option if you want to use the SSO API. To download the accompanying source code for this article, click here. Although BizTalk 2004 has more extensive Web service support than its predecessor, its support has some limitations. You can overcome the limitations using the .NET Framework by wrapping the Web service in a .NET assembly. Once you've wrapped the code in an assembly, you can use it in an Orchestration Expression or even BizTalk Business Rules. Jeffrey Juday is a software developer with Crowe Chizek in South Bend, Indiana. He has been developing software with Microsoft tools for more than 12 years in a variety of industries. Jeff currently builds solutions using BizTalk 2004, ASP.NET, SharePoint, and SQL Server 2000. You can reach Jeff at jjuday@crowechizek.com.
BizTalk 2004 Adapter Alternatives for Handling Web Services
February 1, 2006
Overview of the Example
A Sample .NET Web Service
[WebMethod]
public ArrayList TestInvoke(int idVal, string testName,
int numValues)
{
ArrayList al;
al = new ArrayList();
for (int i=0; i<numValues; ++i)
{
al.Add (testName + i.ToString());
}
return (al);
}
Click here for a larger image. The Orchestration and the Assembly
TestXML ws;
object[] obj;
CredentialCache cred;
NetworkCredential netCred;
string retval;
retval = "";
System.Net.ServicePointManager.CertificatePolicy =
new TestWSTrustCertificatePolicy();
ws = new TestXML();
cred = new CredentialCache();
netCred = new NetworkCredential("****","*****");
cred.Add(new Uri(ws.Url),"Basic",netCred);
ws.Credentials = cred;
obj = ws.TestInvoke(0,"Name value",3);
Authentication and Secure Communication
System.Net.ServicePointManager.CertificatePolicy =
new TestWSTrustCertificatePolicy();
cred = new CredentialCache();
netCred = new NetworkCredential("****","****123#");
cred.Add(new Uri(ws.Url),"Basic",netCred);
Ideas for Your Own Implementation
Securing Credentials
Download the Code
BizTalk 2004 with the .NET Framework
About the Author