home / infca / mq / mq_soap (navigation links) If u buy me a drink, I'll let u kiss me

(1) Concepts | (2) Overview | (3) Installation | (4) Creating Links | End

MQ and WebServices


Amunt! Top Amunt!
(1) - some concepts - getting started
Amunt!

(1) SOAP over Hypertext Transfer Protocol

Process involved in creating and processing the request:

  1. The client invokes a method of a class hosted by the server through a proxy of the class accessible to the client.
  2. The SOAP layer, such as an implementation of SOAP provided by Microsoft .NET, Apache Axis, or WebSphere Application Server, catches the method call and marshalls the function name and parameters, creating a representation of the call in Extensible Markup Language (XML) form.
  3. The XML for the method call is itself wrapped in a SOAP envelope, which is also in XML format.
  4. The data built up so far is then sent to the target service as a HTTP request. Implicitly, this is over TCP/IP.
  5. The HTTP request is received by a HTTP server, typically, a Web server such as the Microsoft Internet Information Services (IIS) or the Apache Web Server.
  6. The SOAP data is passed to the SOAP layer by the HTTP server.
  7. The server side SOAP layer parses the SOAP envelope, extracting the XML representation of the method invocation. It then extracts the data for the method call itself.
  8. The SOAP layer locates the target service and invokes the function desired by the client.
  9. The service runs the function and returns the results.
  10. The results are returned to the client in a similar manner.

(2) SOAP over WebSphere MQ

All the steps are the same as for SOAP/HTTP except for steps 4, 5, and 6. Instead of sending the data using HTTP, the SOAP layer passes the SOAP envelope and contents to a SOAP/WebSphere MQ sender. The SOAP/WebSphere MQ sender puts the SOAP message into a queue as a WebSphere MQ message. A process known as SOAP/WebSphere MQ listener then reads the message from the queue and passes the SOAP data to the server side SOAP layer in the same manner that the Web server does in the case of HTTP. The responses are returned in a similar fashion.

What is SOAP ?

SOAP, the Simple Object Access Protocol, is a protocol for exchange of information in a decentralized, distributed environment. It is an XML (Extensible Markup Language) based protocol that consists of three parts:


For more information see the W3C website
What is a Web service ?

In general there are two parts to a Web service:

The Web request has two parts:

What is a proxy ?

A proxy is a class that presents the same interface and method signatures as the service, but instead of directly implementing the desired behavior, invokes the method remotely. The proxy class is generated from Web Services Description Language (WSDL), and compiled and made available locally as part of the deployment process.

In order to create a client for any Web Service, the developer creating the client requires proxy code. This proxy code allows a client developer to call a remote method as though it is a local method. The proxy hides the complexity of the underlying Web Service infrastructure from the client.

What is WebSphere MQ transport for SOAP ?

WebSphere MQ transport for SOAP allows you to send SOAP formatted messages, used in conjunction with Web services, over WebSphere MQ.

It is implemented for either Apache Axis or Microsoft .NET host environments.
Axis is available on UNIX or Windows platforms, and .NET on Windows only.

MQ Transport for SOAP (pdf)


Amunt! Top Amunt!
(2) - Overview

WebSphere MQ transport for SOAP is based on a traditional request/response model. In the simplest case, using proxy classes, the client program sees this as a remote procedure call.
The SOAP/WebSphere MQ client puts a message to a WebSphere MQ queue. This may be the request queue on the local queue manager or may be a remote queue in which case the message is then transported using WebSphere MQ to the appropriate SOAP/WebSphere MQ request queue.
A dedicated SOAP/WebSphere MQ listener process monitors the request queue for incoming messages and then routes them through to the target Web Service using the appropriate host infrastructure.
Two distinct types of SOAP/WebSphere MQ listener are provided, one for Apache Axis Web Services (SimpleJavaListener) and one for Microsoft .NET web services (amqwSOAPNETListener).
Note that these listeners are distinct from the standard WebSphere MQ listener invoked by the runmqlsr command. The sequence of control for this is as follows:

Client: Client Program (provided by user) Client Proxy (generated by infrastructure [optional for Axis]) WebServices runtime (Axis or .NET infrastructure) SOAP/WebSphere MQ Sender WebSphere MQ | Server: WebSphere MQ SOAP/WebSphere MQ Listener WebServices runtime (Axis or .NET infrastructure) Service Program (provided by user)

The client proxy is shown as optional for Axis because Axis supports three programming styles, only one of which requires a proxy, while .NET always requires a proxy.

Listeners

Generated scripts to manage them:

\\IVT\generated\server endWMQJListener.cmd startWMQJListener.cmd

If you want to run them as a service, specify "-s" to the deployment tool, than will generate defineWMQNlistener.cmd to define the listener as a service.

java com.ibm.mq.soap.transport.jms.SimpleJavaListener -u "jms:/queue?destination=SOAPJ.demos@WMQSOAP.DEMO.QM &connectionFactory=(connectQueueManager(WMQSOAP.DEMO.QM)) &initialContextFactory=com.ibm.mq.jms.Nojndi &targetService=soap.server.StockQuoteAxis.java &replyDestination=SYSTEM.SOAP.RESPONSE.QUEUE" -n 10
Senders

For Axis web services, a sender is implemented in the final class com.ib.mq.soap.transport.jms.WMQSender which is derived from the org.apache.axis.handlers.BasicHandler class.
For Microsoft .NET services, a sender is implemented in the sealed class IBM.WMQSOAP.MQWebRequest. This class is derived from System.Net.WebRequest and System.Net.IwebRequestCreate.


Amunt! Top Amunt!
(3) - Installation

SOAP/WebSphere MQ is installable as part of the standard WebSphere MQ install mechanism.
It is included as part of the "Java Messaging and SOAP Transport" install option in both the server and client installation CDs.

What is installed

The following components are provided with WebSphere MQ transport for SOAP:

CMDs
Pre-requisites

The prerequisites for WebSphere MQ transport for SOAP are:

A version of the Apache Axis runtime is also included in the WebSphere MQ installation media, in the prereqs/axis directory, together with a text file, axis_readme.txt, giving instructions on how to install it. It is not installed as part of the WebSphere MQ installation process. The supplied Axis.jar has been specifically patched.

Directory of \\MQ_v7.5\Prereqs\Axis 04-06-12 01:00 1.599.570 axis.jar // apache axis runtime 04-06-12 01:00 2.060 axis_readme.txt

Copy it to "\\MQ\java\lib\soap"

Verifying the WebSphere MQ transport for SOAP

Verify the WebSphere MQ transport for SOAP using the runivt command. The command runs a number of demonstration applications and ensures that the environment is correctly set up after installation.

Before you begin

Before you run the runivt command, ensure that you have the following runtime environments:

KC 7.5

Syntax
(2) .- -c ivttests_unix.txt-----. | (1) | .--------------. +- -c ivttests.txt----------+ .- hold---. V | >>-runivt--+-----+--+---------------------------+--+---------+----+----------+-+->< '- -v ' '- -c -configFile-----------' '-killall-' '-testName-'
Testing your SOAP/MQ installation

Before running the IVT, set the environment variable WMQSOAP_HOME to specify the WebSphere MQ installation directory.

Change to a directory under which you want the IVT to deploy. Run the IVT by executing the \\MQ\tools\soap\Samples\runivt.cmd script.

The full set of tests can be executed by entering the command "runivt" with no arguments.
If you want to use the IVT to run only a single test, the name of the test should be the first argument supplied to the utility.

c:\temp\mq> echo %WMQSOAP_HOME% c:\MQ c:\temp\mq> call c:\MQ\tools\soap\Samples\runivt.cmd --------------------------------------------------------- WebSphere MQ Transport for SOAP Install Verification Test --------------------------------------------------------- NB. If failures occur run SOAPCleanup.cmd before re-running the test Checking the environment > ------------------------------------------- Successful Checking and configuring the .NET environment ERROR The .NET environment is not correctly configured. Run the test from either a Visual Studio or .NET SDK command prompt to ensure your PATH is configured correctly. See the runivt.log file in the current directory for further details of the failure. Run the SOAPCleanup.cmd before re-running. c:\temp\mq> type runivt.log 'csc' is not recognized as an internal or external command, operable program or batch file. c:\temp\mq> call c:\MQ\tools\soap\Samples\SOAPCleanup.cmd WebSphere MQ Transport for SOAP environment clean up Ending any MQ Listeners 24/12/2014 21:01:07 AMQ9243: The queue manager 'WMQSOAP.DEMO.QM' does not exist. Ending the Queue Manager AMQ8118: WebSphere MQ queue manager does not exist. Removing the queue manager from the system AMQ8118: WebSphere MQ queue manager does not exist. Removing any files/directories generated from pervious sample runs The system cannot find the file specified. The system cannot find the file specified. The system cannot find the file specified. The system cannot find the file specified. c:\temp\mq> dir c:\csc.exe /s Directory of c:\Windows\Microsoft.NET\Framework64\v4.0.30319 11-09-13 19:39 2.682.424 csc.exe Directory of c:\Program Files (x86)\MSBuild\12.0\Bin\amd64 04-10-13 23:58 2.631.344 csc.exe

If we run it from "VS2013 Developer Command Prompt", then it improves a bit:

C:\temp\mq>echo c:\MQ c:\MQ C:\temp\mq>call c:\MQ\tools\soap\Samples\runivt.cmd --------------------------------------------------------- WebSphere MQ Transport for SOAP Install Verification Test --------------------------------------------------------- NB. If failures occur run SOAPCleanup.cmd before re-running the test Checking the environment (both) > ------------------------------------------- Successful (WMQSOAP_HOME) Checking and configuring the .NET environment > ------------------------------------------- Successful (CSC) > ------------------------------------------- Successful (WSDL) Checking and configuring the Java environment > ------------------------------------------- Successful (JAVA) > ------------------------------------------- Successful (JAVAC) fem "c:\MQ\bin\amqwsetcp.cmd" ERROR Error - axis.jar not found Please copy the required Axis jar files from the WebSphere MQ installation CD. If the files are copied to other than "c:\MQ\java\lib\soap", edit 'amqwsetcp.cmd' so that it looks for axis.jar in the right place and also set up the CLASSPATH correctly.

El que tenim es

c:\MQ\java\lib\soap> dir 08-03-13 18:44 71.442 commons-discovery-0.2.jar 08-03-13 18:44 38.015 commons-logging-1.0.4.jar 08-03-13 18:44 31.191 jaxrpc.jar 08-03-13 18:44 18.979 saaj.jar 08-03-13 18:44 36.202 servlet.jar 08-03-13 18:44 126.771 wsdl4j-1.5.1.jar

I al disc

Directory of \\MQ_v7.5\Prereqs\Axis 04-06-12 01:00 1.599.570 axis.jar

Un cop posem el fitxer a lloc, avancem un altre petit pas:

Fem "c:\MQ\bin\amqwsetcp.cmd" > ------------------------------------------- Successful (AMQWSETCP) Setting up the Queue Manager and req/resp queues (setupWMQSOAP.cmd) CRTMQM WMQSOAP.DEMO.QM STRMQM WMQSOAP.DEMO.QM RUNMQLSR WMQSOAP.DEMO.QM 9414 +++ define few objects --- define few objects > -------------------------------------- Successful (SETUPWMQSOAP) . Deploying the .NET service (copy) Deploying the .NET service (amqwdeploy) RunCommand: Command = amqswsdl jms:/queue?destination=SOAPN.demos@WMQSOAP.DEMO.QM &connectionFactory=(connectQueueManager(WMQSOAP.DEMO.QM)) &initialContextFactory=com.ibm.mq.jms.Nojndi &targetService=StockQuoteDotNet.asmx &replyDestination=SYSTEM.SOAP.RESPONSE.QUEUE StockQuoteDotNet.asmx generated\StockQuoteDotNet_Wmq.wsdl 5724-H72 (C) Copyright IBM Corp. 1994, 2011. ALL RIGHTS RESERVED. Failure in building WSDL ERROR The .NET service failed to deploy. See runivt.log for details, located in the current directory.

Here it says :
On Windows, if errors are reported from amqswsdl, try issuing the following command to register .asmx files as services.

%windir%/Microsoft.NET/Framework/version number/aspnet_regiis.exe -ir

The problem typically occurs on systems where IIS has not been installed, or IIS has been installed after NET. The problem is encountered when amqswsdl generates the .wsdl files. Note: The registry keys are also required to permit the listener to invoke the services. If you use your own customized deployment procedures, you might not encounter the problem until run time.

C:\temp\mq> c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir Microsoft (R) ASP.NET RegIIS version 4.0.30319.18408 Administration utility to install and uninstall ASP.NET on the local machine. Copyright (C) Microsoft Corporation. All rights reserved. Start installing ASP.NET (4.0.30319.18408) without changing existing web applications to use this version of ASP.Net. .... Finished installing ASP.NET (4.0.30319.18408) without changing existing web applications to use this version of ASP.Net.

Still

Deploying the .NET service (amqwdeploy) RunCommand: Command = amqswsdl jms:/queue?destination=SOAPN.demos@WMQSOAP.DEMO.QM &connectionFactory=(connectQueueManager(WMQSOAP.DEMO.QM)) &initialContextFactory=com.ibm.mq.jms.Nojndi &targetService=StockQuoteDotNet.asmx &replyDestination=SYSTEM.SOAP.RESPONSE.QUEUE StockQuoteDotNet.asmx generated\StockQuoteDotNet_Wmq.wsdl 5724-H72 (C) Copyright IBM Corp. 1994, 2011. ALL RIGHTS RESERVED. Failure in building WSDL ERROR
AMQERR01.LOG message

Everytime building WSDL fails, we have a message in MQ log :

----- MQWSDL.Main : 0 --------------------------------------------------------- 27/12/2014 20:27:18 - Process(4760.1) User(sp10304) Program(amqswsdl.exe) Host(YIP250RH) Installation(InstallationSAG) VRMF(7.5.0.1) AMQ9920: A SOAP Exception has been thrown. EXPLANATION: A SOAP method encountered a problem and has thrown an exception. Details of the exception are: 'System.IO.FileNotFoundException: Could not load file or assembly 'amqswsdl, Version=7.5.0.1, Culture=neutral, PublicKeyToken=c64a1a75b5c110e8' or one of its dependencies. The system cannot find the file specified. File name: 'amqswsdl, Version=7.5.0.1, Culture=neutral, PublicKeyToken=c64a1a75b5c110e8'---> System.IO.FileNotFoundException: Could not load file or assembly 'amqswsdl, Version=7.5.0.1, Culture=neutral, PublicKeyToken=c64a1a75b5c110e8' or one of its dependencies. The system cannot find the file specified. File name: 'amqswsdl, Version=7.5.0.1, Culture=neutral, PublicKeyToken=c64a1a75b5c110e8' WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at System.UnitySerializationHolder.GetRealObject(StreamingContext context) at System.Web.Hosting.HostingEnvironment.CreateInstance(Type type) at System.Web.Hosting.ApplicationHost.CreateApplicationHost(Type hostType, String virtualDir, String physicalDir) at MQWSDL.Main(String[] args) ' ACTION: Investigate why the SOAP method threw the exception. ----- MQWSDL.Main : 0 ---------------------------------------------------------
RUNIVT.CMD ok

On a "fresh" machine (win 7, mq 7.5.0.0, VS 12, Java 1.8.0_05) all works ok

MQJE001: Completion Code '2', Reason '2495'

(url) If you are generating a 64-bit Java program, and your PATH envir var has the libs in this order :

C:\MQ\java\lib;C:\MQ\java\lib64;

Amunt! Top Amunt!
(4) - Creating and deploying a Web service using WebSphere MQ transport for SOAP

Samples for Java:
The following sample services and client applications are supplied for the Java environment. These can all be run using the supplied IVT.

We shall use "Axis" even under guindows, as there is some problem with .Net and "amqwdeployWMQService.cmd"

Transport for SOAP (pdf)


Amunt! Top Amunt!
(5) - Programming for WebSphere MQ transport for SOAP
Languages supported

Apache Axis client and service applications must be written in Java.

Microsoft .NET client and service applications must be written in C#, Visual Basic, or other .NET CLR languages.

Client programming

For Java, WebSphere MQ provides access to web services using the Apache Axis Web Services infrastructure.

Axis supports three programming styles: SOAP style, WSDL style and PROXY style.

All three of these styles are supported in the SOAP/WebSphere MQ Java client environment.
However, SOAP style offers limited flexibility and ease of use. So, samples are provided only for WSDL and Proxy styles.

WSDL style

Sample \\mq/tools/soap/samples/java/clients/WsdlClients.java shows an example of a simple Java client WebSphere MQ transport test.
This calls an Axis service from an Axis client environment using WSDL Axis calls.
The programmer is responsible for referencing the correct WSDL (which can be held locally or accessed over HTTP), and using appropriate ports and bindings.

Proxy style

Sample \\mq/tools/soap/samples/java/clients/SqAxis2Axis.java is an example of a simple Java WebSphere MQ transport test.
This calls an Axis service from an Axis client environment using automatically generated proxy classes.
The programmer must reference the correct proxies, and the proxies will have been generated to get the remaining information correct.

Service programming

Samples
\\MQ\tools\soap\Samples\java\clients (SQAxis2Axis.java) & \\MQ\tools\soap\Samples\java\server (StockQuoteAxis.java)

Amunt! Top Amunt!
(6) - Specifying the URI

A web service is specified using a Universal Resource Identifier (URI). This section specifies the URI format that is supported in WebSphere MQ transport for SOAP.

The URI syntax is as follows:

jms:/queue?name=value&name=value...

This is an example of a simple URI for an Axis service:

jms:/queue?destination=myQ&connectionFactory=()&initialContextFactory=com.ibm.mq.jms.Nojndi

Amunt! Top Amunt!
(7) - Deployment

Deployment is the process of configuring the host web services infrastructure (Axis or Microsoft .NET) to recognize the prepared web service.

A deployment utility is provided as part of WebSphere MQ transport for SOAP. This consists of a Java program, com.ibm.mq.soap.util.amqwdeployWMQService, and command files amqwdeployWMQService.sh and amqwdeployWMQService.cmd, which invoke it {c:\MQ\bin\}.

c:\MQ\bin> type amqwdeployWMQService.cmd echo +++ Fem amqwdeployWMQService.cmd java -Dwmqsoap.home=. com.ibm.mq.soap.util.DeployWMQService %* if NOT %errorlevel% == 0 exit /b 1 exit /b 0

Source code functionally equivalent to amqwdeployWMQService is also supplied so you can use it as the basis of your own deployment utility : {\\MQ\tools\soap\Samples\DeployWMQService.java}

amqwdeployWMQService : parameters, syntax, actions

Syntax diagram

Required parameters -f className className is the name of the class to be deployed. For Axis services, className is the Java source file, and for .NET services, the .asmx file.

Steps or actions and verifications


Amunt! Top Amunt!
Let's make it run

Editem el servidor:

\\MQ\tools\soap\Samples\java\server> np StockQuoteAxis.java return( (float) 58.25 );

Editem els clients:

\\MQ\tools\soap\Samples\java\clients> np SQAxis2Axis.java +++ [axis] Response: 55.25 c:\MQ\tools\soap\Samples\java\clients> np WsdlClient.java +++ [wsdl client] Response: 55.25

Editem test:

\\MQ\tools\soap\Samples\java\clients> np RunIvt.java +++ runivt.java OK.

Esborrem anterior:

C:\temp\mq\generated> del soap.server.StockQuoteAxis_Wmq.wsdl

Generem entorn nou (as runivt.class) i executem els 3 tests:

c:\temp\mq> c:\MQ\tools\soap\Samples\runivt Axis

O be, executem un sol test:

c:\temp\mq> java soap.clients.RunIvt AxisWsdl c:\temp\mq> java soap.clients.RunIvt AxisProxy c:\temp\mq> java soap.clients.RunIvt AxisProxyClient ----- [AxisWsdl] -------------------------------- WMQ transport test: Axis to Axis, using WSDL Axis calls +++ server: generated\server\startWMQJListener.cmd --- client: java soap.clients.WsdlClient start WsdlClient demo, wsdl port soap.server.StockQuoteAxis_Wmq resolving uri to ... 'jms:/queue?destination=SOAPJ.demos@WMQSOAP.DEMO.QM &connectionFactory=(connectQueueManager(WMQSOAP.DEMO.QM)) &initialContextFactory=com.ibm.mq.jms.Nojndi &targetService=soap.server.StockQuoteAxis.java &replyDestination=SYSTEM.SOAP.RESPONSE.QUEUE' +++ [axis] Response: 55.25 +++ runivt.java OK. ----------------------------------

De fet, un sol test hauria de ser aixi, pero no va be:

c:\temp\mq> echo POSA.CMD - extret de SAG.CMD java soap.clients.SQAxis2Axis jms:/queue?destination=SOAPJ.demos@WMQSOAP.DEMO.QM &ConnectionFactory=connectQueueManager(WMQSOAP.DEMO.QM) &replyDestination=SYSTEM.SOAP.RESPONSE.QUEUE &initialContextFactory=com.ibm.mq.jms.Nojndi

Els 3 test Axis i els 3 de DotNet i el conjunt son :

echo Running 3 Axis samples ... java soap.clients.RunIvt AxisWsdl AxisProxy AxisProxyclient echo Running .NET samples ... java soap.clients.RunIvt Dotnet DotnetClient DotnetVB echo Running all samples (including Axis/.NET interops) ... java soap.clients.RunIvt

From AMQERR01.LOG entry, we find

To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.

From now on, when I run "runivt.cmd DOTNET", a FDC is created, containing "System.IO.FileNotFoundException"

Own files

Lets split runivt.cmd into parts:


Amunt! Top Amunt!
Links

Ep ! Valid HTML 4.01!   Valid CSS! Escriu-me !
Updated 20150108 (a)  
Uf !