Patterns Direct Connections for Intra- And Inter-Enterprise. Direct Connections for Intra- And Inter-Enterprise (IBM Redbook) (Paperback)

 < Day Day Up > 


9.5 Integration with .NET-based Web services

In this section we take a brief look at interoperability between WebSphere V5.0.2 and Microsoft .NET Web services, which use the wrapped document style. Figure 9-7 shows a Runtime pattern and Product mapping providing connectivity between IBM WebSphere Application Server V5.0.2 and Microsoft .NET using the Direct Connection pattern.

Figure 9-7: Direct Connection--Call Connection- Web services to .NET Product mapping

You can find a number of .NET Web service providers on the Internet, with a search on "web service directory" in popular search engines. One of the sites, WebserviceX.NET provides a number of .NET Web services for general consumption. You can access the WebserviceX.NET Web site at:

To demonstrate interoperability with .NET Web services, we downloaded the WSDL for the WebserviceX.NET SendEmail service from:

Using this WSDL file, we generated the Web service client deployment descriptors and classes using the WebSphere V5.0.2 WSDL2Java tool. We used the command shown in Example 9-15.

Example 9-15: Generating client deployment descriptors and classes using WSDL2Java

C:\WebSphere\AppServer\bin\WSDL2Java -verbose -role client -container web -output C:\workspace\ITSOSourceAppWeb\WebContent C:\workspace\ITSOSourceAppWeb\WebContent\WEB-INF\wsdl\SendEmail.wsdl WSWS3185I: Info: Parsing XML file: C:\...\WEB-INF\wsdl\SendEmail.wsdl WSWS3282I: Info: Generating C:\...\NET\webserviceX\www\SendEmailSoap.java. WSWS3282I: Info: Generating C:\...\NET\webserviceX\www\SendEmailSoapStub.java. WSWS3282I: Info: Generating C:\...\NET\webserviceX\www\SendEmail.java. WSWS3282I: Info: Generating C:\...\NET\webserviceX\www\SendEmailLocator.java. WSWS3282I: Info: Generating C:\...\WEB-INF\webservicesclient.xml. WSWS3282I: Info: Generating C:\...\WEB-INF\ibm-webservicesclient-bnd.xmi. WSWS3282I: Info: Generating C:\...\WEB-INF\ibm-webservicesclient-ext.xmi. WSWS3282I: Info: Generating C:\...\WEB-INF\SendEmail_mapping.xml.

We then refreshed the ITSOSourceAppWeb project in WebSphere Studio and moved the generated NET.webserviceX.www package in the ITSOSourceAppWeb\WebContent folder to the ITSOSourceAppWeb\JavaSource folder.

The generated files are highlighted in Figure 9-8.

Figure 9-8: Generated client binding files and deployment descriptors

Next we added client application code to invoke the Web service on the target application. To create an e-mail message containing the part number for the Update Inventory use case, we added the code shown in Example 9-16. We added this code to the com.ibm.itso.command. WebServiceNetBean command bean in our ITSOSourceAppWeb module.

Example 9-16: Web service client code for updateInventory using .NET service

public void updateInventory(String partNumber) throws Exception { try { // Send the order Context ctx = new InitialContext(); String emailSender = (String) ctx.lookup("java:comp/env/EmailSender"); String emailReceiver = (String) ctx.lookup("java:comp/env/EmailReceiver"); SendEmail service = (SendEmail) ctx.lookup("java:comp/env/service/SendEmail"); // Request the Port Object from it SendEmailSoap endPoint = service.getSendEmailSoap(); endPoint.sendEmails(emailSender, emailReceiver, "ABC Electronics order", "Please order: " + partNumber); } catch (Exception e) { //... } return; }

We tested the source application in the IBM WebSphere Studio Application Developer V5.1 test environment and in the IBM WebSphere Application Server V5.0.2 runtime environment. The .NET SOAP request for updateInventory is shown in Example 9-17.

Example 9-17: SOAP request for updateInventory

POST /SendEmail.asmx HTTP/1.0 Content-Type: text/xml; charset=utf-8 Accept: application/soap+xml, application/dime, multipart/related, text/* User-Agent: IBM WebServices/1.0 Host: www.webservicex.net Cache-Control: no-cache Pragma: no-cache SOAPAction: "http://www.webserviceX.NET/SendEmails" Content-Length: 556 <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <SendEmails xmlns="http://www.webserviceX.NET"> <ToEmailAddress>aaa@bbb.ccc</ToEmailAddress> <FromEmailAddress>aaa@bbb.ccc</FromEmailAddress> <Subject>ABC Electronics order</Subject> <Body>Please order: 12345</Body> </SendEmails> </soapenv:Body> </soapenv:Envelope>

The .NET SOAP response for updateInventory is shown in Example 9-18.

Example 9-18: SOAP response for updateInventory

HTTP/1.1 200 OK Server: Microsoft-IIS/5.0 Date: Mon, 08 Sep 2003 01:22:16 GMT Cache-Control: private, max-age=0 Content-Type: text/xml; charset=utf-8 Content-Length: 389 <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <SendEmailsResponse xmlns="http://www.webserviceX.NET"> <SendEmailsResult>Your Message send successfully</SendEmailsResult> </SendEmailsResponse> </soap:Body> </soap:Envelope>

Example 9-19 shows the delivered e-mail.

Example 9-19: The e-mail delivered by the SendEmail service

From: aaa@bbb.ccc To: aaa@bbb.ccc Subject: ABC Electronics order Date: Sun, 7 Sep 2003 21:22:15 -0400 Please order: 12345

Unfortunately, we can't guarantee that your WebSphere to .NET Web services integration experience will be this smooth!


 < Day Day Up > 

Категории