Programming Web Services

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

BEA SALT Client Programming

This chapter contains the following client programming topics:

 


Overview

BEA SALT is a configuration-driven product that publishes existing Tuxedo application services as industry-standard Web services. From a Web services client-side programming perspective, BEA SALT used in conjunction with the BEA Tuxedo framework is a standard Web service provider. You only need to use the BEA SALT WSDL document to develop a Web service client program.

To develop a Web service client program, follow these steps:

  1. Generate or download the BEA SALT WSDL document/file. See Configuring BEA SALT in the BEA SALT Administration Guide for more information on generating the BEA SALT WSDL document.
  2. Use a Web service client-side toolkit to parse the SALT WSDL document and generate client stub code. See BEA SALT Web Service Client Programming Tips.
  3. Write client-side application code to invoke a BEA SALT Web service using the functions defined in the client-generated stub code.
  4. Compile and run your client application.

 


BEA SALT Web Service Client Programming Tips

This section provides some useful client-side programming tips for developing Web service client programs using the following BEA SALT-tested programming toolkits:

See Interoperability Considerations in the BEA SALT Administration Guide for more information.

Notes: You can use any SOAP toolkit of your choice to develop client software.
Note: The sample directories for the listed toolkits can be found after BEA SALT is installed.

BEA WebLogic Web Service Client Programming Toolkit

WebLogic Server provides the clientgen utility which is a built-in application server component used to develop Web service client-side java programs. The invocation can be issued from standalone java program and server instances. For more information, see http://download.oracle.com/docs/cd/E13222_01/wls/docs91/webserv/client.html#standalone_invoke.

Besides traditional synchronous message exchange mode, BEA SALT also supports asynchronous and reliable Web service invocation using WebLogic Server. Asynchronous communication is defined by the WS-Addressing specification. Reliable message exchange conforms to the WS-ReliableMessaging specification. For more information, see BEA SALT Sample Applications on page 1-7.

Tip: Use the WebLogic specific WSDL document for HTTP MIME attachment support.

BEA SALT can map Tuxedo CARRAY data to SOAP request MIME attachments. This is beneficial when the binary data stream is large since MIME binding does not need additional encoding wrapping. This can help save CPU cycles and network bandwidth.

Another consideration is, in an enterprise service oriented environment, binary data might be used to guide high-level data routing and transformation work. Encoded data can be problematic. To enable the MIME data binding for Tuxedo CARRAY data, a special flag must be specified in the WSDL document generation options, both for online downloading and using the tmwsdlgen command utility.

Online Download:
http://salt.host:portnumber//wsdl?mappolicy=raw&toolkit=wls

tmwsdlgen Utility
tmwsdlgen -c SALT_CONFFILE -m raw -t wls

Apache Axis for Java Web Service Client Programming Toolkit

BEA SALT supports the AXIS wsdl2java utility which generates java stub code from the WSDL document. The AXIS Web service programming model is similar to WebLogic. For more information, see BEA SALT Sample Applications on page 1-7.

Tip: 1. Use the AXIS specific WSDL document for HTTP MIME attachment support.

BEA SALT supports HTTP MIME transportation for Tuxedo CARRAY data. To achieve this, a special option must be specified for WSDL online downloading and the tmwsdlgen utility.

Online Download:
http://salt.host:portnumber//wsdl?mappolicy=raw&toolkit=axis

tmwsdlgen Utility
tmwsdlgen -c SALT_CONFFILE -m raw -t axis
Tip: 2. Disable multiple-reference format in AXIS when RPC/encoded style is used.

AXIS may send a multi-reference format SOAP message when RPC/encoded style is specified for the WSDL document. BEA SALT does not support multiple-reference format. You can disable AXIS multiple-reference format as shown in Listing 1-1:
Listing 1-1 Disabling AXIS Multiple-Reference Format
TuxedoWebServiceLocator  service = new TuxedoWebServiceLocator();
service.getEngine().setOption("sendMultiRefs", false);
¦
Tip: 3. Use Apache Sandensha project with BEA SALT for WS-ReliableMessaging communication.

Interoperability was tested for WS-ReliableMessaging between BEA SALT and the Apache Sandensha project. The Sandensha asynchronous mode and send offer must be set in the code.

A sample Apache Sandensha asynchronous mode and send offer code example is shown in Listing 1-2:
Listing 1-2 Sample Apache Sandensha Asynchronous Mode and "send offer" Code example
/* Call the service */ 
TuxedoWebService service = new TuxedoWebServiceLocator();

Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext();

ctx.setAcksToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
ctx.setReplyToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
ctx.setSendOffer(true);
ctx.initCall(call, targetURL, "urn:wsrm:simpapp", Constants.ClientProperties.IN_OUT);

call.setUseSOAPAction(true);
call.setSOAPActionURI("ToUpperWS");
call.setOperationName(new javax.xml.namespace.QName("urn:pack.simpappsimpapp_typedef.salt11", "ToUpperWS"));
call.addParameter("inbuf", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);

String input = new String();
String output = new String();
int i;
for (i = 0; i < 3; i++ ) {
input = "request" + "_" + String.valueOf(i);

System.out.println("Request:"+input);
output = (String) call.invoke(new Object[]{input});
System.out.println("Reply:" + output);
	    }

ctx.setLastMessage(call);
input = "request" + "_" + String.valueOf(i);
System.out.println("Request:"+input);
output = (String) call.invoke(new Object[]{input});

Microsoft .NET Web Service Client Programming Toolkit

Microsoft .Net 1.1/2.0 provides wsdl.exe in the .Net SDK package. It is a free development Microsoft toolkit. In the BEA SALT simpapp sample, a .Net program is provided in the simpapp/dnetclient directory.

.Net Web service programming is easy and straightforward. Use the wsdl.exe utility and the BEA SALT WSDL document to generate the stub code, and then reference the .Net object contained in the stub code/binary in business logic implementations. For more information, see BEA SALT Sample Applications on page 1-7.

Tip: 1. Do not use .Net program MIME attachment binding for CARRAY.

Microsoft does not support SOAP communication MIME binding. Avoid using the WSDL document with MIME binding for CARRAY in .Net development.

BEA SALT supports base64Binary encoding for CARRAY data (the default WSDL document generation.)
Tip: 2. Some RPC/encoded style SOAP messages are not understood by the GWWS server.

When the BEA SALT WSDL document is generated in RPC/encoded style, .Net will send out SOAP messages containing soapenc:arrayType. BEA SALT does not support soapenc:arrayType in RPC/encoded style. A sample RPC/encoded style-generated WSDL document is shown in Listing 1-3.
Listing 1-3 Sample RPC/encoded Style-Generated WSDL document

<wsdl:types>

<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:pack.TuxAll_typedef.salt11">
<xsd:complexType name="fml_TFML_In">
<xsd:sequence>
<xsd:element maxOccurs="60" minOccurs="60" name="tflong" type="xsd:long"></xsd:element>
<xsd:element maxOccurs="80" minOccurs="80" name="tffloat" type="xsd:float"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="fml_TFML_Out">
...

</xsd:complexType>

</xsd:schema>

</wsdl:types>

Workaround: Use Document/literal encoded style for .Net client as recommended by Microsoft.

Tip: 3. Error message regarding xsd:base64Binary in RPC/encoded style.

If xsd:base64Binary is used in the BEA SALT WSDL document in RPC/encoded style, wsdl.exe can generate stub code, but the client program might report a runtime error as follows:

System.InvalidOperationException:'base64Binary'
is an invalid value for the SoapElementAttribute.DataType property. The property may only be specified for primitive types.

Workaround: This is a .Net framework issue.
Use Document/literal encoded style for .Net client as recommended by Microsoft.

 


BEA SALT Sample Applications

BEA SALT bundles six Web service sample applications to demonstrate how to invoke BEA SALT using BEA WebLogic, Apache Axis or Microsoft .NET toolkits.

After BEA SALT is installed, you can find the following sample applications for your reference in the BEA SALT sample directory (each sample contains a detailed readme file):

Note: UNIX samples: $TUXDIR/samples/salt

Windows samples: %TUXDIR%\samples\salt

Basic Sample

The Basic Sample demonstrates how to export a simple Tuxedo service as a Web service. The Tuxedo simpapp sample is used as an existing application to be exported as a Web service.

This sample contains all needed files to configure and export the simpserv server TOUPPER service as a Web service. The Web service accepts a single a string parameter and converts it to uppercase. The client calls the service, and then prints the returned string.

This sample will enable you to learn the basics of running and accessing the GWWS server and the Web Services it provides.

Applicable Client Programs(s): BEA WebLogic, Apache Axis for Java, Microsoft .NET.

Attachment Sample

The Attachment Sample demonstrates how to transport CARRAY buffer types as MIME attachments according to SwA Protocol (SOAP with Attachment) in a SALT Web service. The Tuxedo simpapp sample is used as an existing application to be exported as a Web service. This sample contains all needed files to configure and export the simpserv server TOUPPER service as a Web Service.

Applicable Client Programs(s): BEA WebLogic.

Custom Type Sample

The BEA Salt 1.1 Custom Type Plug-in Sample demonstrates how to use Salt 1.1 plug-in extension mechanisms to implement customized mapping rules between Tuxedo Custom Typed Buffers and XML documents.

Applicable Client Programs(s): BEA WebLogic.

Data Type Sample

The Date Type Sample demonstrates how Tuxedo typed buffer are used in BEA SALT. In this sample shows how the FML and VIEW buffers and their sub-fields are defined in the Tuxedo Service Metadata Repository, and represented in a WSDL document. The WSDL document file generation utility, tmwsdlgen is used in this sample.

A WebLogic client program is also provided in this sample to help you get familiar with Web service client programming. The Tuxedo application server is a simple echo service in which the FML/VIEW buffer are checked and return the input data.

Applicable Client Programs(s): BEA WebLogic.

Reliable Messaging Sample

This ReliableMessaging Sample demonstrates how to use BEA SALT WS-Reliable Messaging support and asynchronous communication with WS-Addressing. The Tuxedo bankapp sample is used as the Tuxedo application service provider. A WebLogic Server Web service client and standalone java Web service client are also included in this sample.

For more detailed WebLogic Server reliable messaging usage information, see http://download.oracle.com/docs/cd/E13222_01/wls/docs91/webserv/advanced.html#reliable_messaging.

Applicable Client Programs(s): BEA WebLogic.

Security Sample

The Security Sample leverages the existing Tuxedo xmlstockapp sample in a stock price query scenario. The STOCKQUOTE service is exported as a Web service by the GWWS server.

BEA SALT uses SSL/HTTPS to secure transport and message. It also supports Tuxedo authentication with HTTP Basic Authentication. You will learn how to configure security transport and how to authenticate using two Tuxedo authentication patterns: application password and user authentication.

A client program can be developed from the code in the sample combined with stub codes generated from the WSDL document. The WSDL document file is generated using the SALT configuration file and the tmwsdlgen utility.

Applicable Client Programs(s): BEA WebLogic.

 


Web Service Client Programming References


  Back to Top       Previous  Next