Problem:
Deploying a web service and creating a COBOL client for that service in Visual Studio 2005 and Net Express v5.0
Resolution:
Steps:
Creating the Web Service:
Create a blank solution in VS
File | New | Project | Other Project Types | Visual Studio Solutions | Blank Solution
Add a new web service or an existing one
In Solution Explorer, Right click on the solution, Add | New Web Site (or Exisitng Web Site)
For New Web Site, in the Language dropdown choose COBOL, then the ASP.NET Web Service Template.
The Template already has a Hello World method. Add any methods you want, rebuild and save.
Deploying the Web Service:
In Solution Explorer, right click on the solution, Add | New Project | Other Project Type | Setup and Deployment | Web Setup Project
Under File System on Target Machine, make sure Web Application Folder is selected, then go to Solution Explorer and right click on your Web Setup Project. Select Add | Project Output. In the project dropdown make sure your Web Service project is selected. Select Content Files and click OK. Right click on the project and Select Rebuild. If it builds succesfully it will create an msi file. Find this file in Windows Explorer and run it. It will install the Web Service on your machine. After it is finished you can view the web service using IIS.
Creating a COBOL client for the Web Service:
Create a new COBOL Application. Right click on the project in Solution Explorer and Add Web Reference. Click on the link for Web Services on Local Machine. Add the web service you just created. Add an entry in the repository for this web service. Create an instance of the web service. Invoke its methods.
Example:
The Cobol App that was created is called CobolWebClient. The web reference is called localhost (that is the default when adding a web reference). The Application is a Cobol Web Form with a button (Button1) and a Label (label1). When the button is clicked it invoke the HelloWorld method which returns a string. The text of label1 is set to this string
Repository.
Class webSrvClass as "CobolWebClient.localhost.Service"
object.
working-storage section.
01 webService object reference webSrvClass.
method-id. "button1_Click" final private.
local-storage section.
01 returnedMessage String.
linkage section.
01 sender System-Object.
01 e System-EventArgs.
procedure division using by value sender e.
invoke webSrvClass::"New" returning webService
set returnedMessage to webService ::"HelloWorld"()
set label1::"Text" to returnedMessage
exit method.
end method "button1_Click".
end object.
