Developing a .NET 1 or 2 service for IBM MQ transport for SOAP using Microsoft Visual Studio 2012
Develop the SampleStockQuote web service for .NET 1 or .NET 2 using Microsoft Visual Studio 2012.
Create the StockQuote service with a code-behind implementation using Microsoft Visual Studio
2012.
Procedure
-
Create a template for the service, and check that it runs on HTTP.
- Start Visual Studio 2012 > File > New > Project.... Select C# Project Type, ,NET Framework 2, and ASP.NET Web Service Application. Type the Name: and Solution Name: StockQuoteDotNet > OK
- Right click Service1.asmx in the Solution Explorer > Rename > StockQuote.asmx.
- Change the code fragment public class Service1 to public class StockQuote.
-
Right click StockQuote.asmx in the Solution Explorer > Open with... > XML Editor. Change Class=
StockQuoteDotNet.Service1
to Class=StockQuoteDotNet.StockQuote
- Change the code fragment [WebService(Namespace = "http://tempuri.org/")] to [WebService(Namespace = "http://stock.samples/")].
- Remove the line of code [ToolboxItem(false)].
- Check everything is correct so far: Debug > Start Debugging (F5). Verify the output in Explorer.
-
Add the methods from the sample SQDNNonInline.asmx.cs, and test the service on HTTP.
- Open MQ_INSTALLATION_PATH \tools\soap\samples\dotnet\SQDNNonInline.asmx.cs and replace the HelloWorld method with the four Quote methods; see Figure 1. MQ_INSTALLATION_PATH represents the directory where IBM MQ is installed.
- Build > Rebuild the solution > Right click one of the Thread in error > Resolve > Using System.Threading.
- Press F5 to start debugging. The service is not conformant to WS-I Basic Profile v1.1. You have the choice of either changing the WebMethod annotation from [SoapRpcMethod] to [SoapDocumentMethod], or removing the annotation [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)].
- Press F5 to verify the implementation using HTTP.
-
Generate WSDL, clients, and run the service using IBM MQ transport for SOAP.
- Open a command window in the project directory tree, where the StockQuote.asmx is stored.
-
(Optional) Use amqwdeployWMQService to generate artifacts. The queue manager must be started:
amqswdeployWMQService -f StockQuote.asmx -u "jms:/queue?initialContextFactory=com.ibm.mq.jms.Nojndi &connectionFactory=() &destination=REQUESTDOTNET@QM1 &targetService=StockQuote.asmx" StockQuote.asmx StockQuote.wsdl
All artifacts are created in the ./generated directory tree. -
(Optional) Generate just the WSDL for calling the service using IBM MQ transport for SOAP.
amqswsdl -u "jms:/queue?initialContextFactory=com.ibm.mq.jms.Nojndi &connectionFactory=() &destination=REQUESTDOTNET@QM1 &targetService=StockQuote.asmx" StockQuote.asmx StockQuote.wsdl
-
Run the .NET listener. Either use .\generated\server\startWMQNListener.cmd or type the command:
amqSOAPNETListener -u "jms:/queue?initialContextFactory=com.ibm.mq.jms.Nojndi &connectionFactory=() &destination=REQUESTDOTNET@QM1 &targetService=StockQuote.asmx"
- Test the service using a client generated from the WSDL, or using the clients generated by amqwdeployWMQService.
Sample code
The sample .NET web service, StockQuoteDotNet, is installed in MQ_INSTALLATION_PATH \tools\soap\samples\dotnet. MQ_INSTALLATION_PATH is the directory where IBM MQ is installed. The web service binding of the published samples differ slightly from the binding used in the task. The task uses the defaults used in Microsoft Visual Studio 2012.
There are two examples of .NET Framework 1 and .NET Framework 2 web services. StockQuoteDotNet.asmx, is an inline service. SQDNNoninline.asmx, is a code-behind web service implemented by SQDNNoninline.asmx.cs.
StockQuoteDotNet has four methods:- float getQuote(String symbol)
- void getQuoteOneWay(String symbol).
- int asyncQuote(int delay)
- float getQuoteDOC(String symbol)