This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Building Web Service Clients
WSO2 Governance Registry can be used as a SOA Registry to store artifacts such as WSDL, Schema and Policy. You can point to the WSO2 Governance Registry using Microsoft Visual Studio and build Web Service Clients using the .NET framework in a few easy steps. Read more to understand how to connect to WSO2 Governance Registry from Visual Studio to discover Web Services and build clients.
Pre - Requirements
In order to connect to WSO2 Governance Registry from Visual Studio, you must first do the following:
1. Start the WSO2 Governance Registry by running the appropriate script from GREG_HOME/bin
.
For Windows:
wso2server.bat --run
For Linux:
sh wso2server.sh
See Starting Governance Registry Management Console on Windows or Starting Governance Registry Management Console on Linux.
Tip
Though this sample will only work in a Windows environment, the WSO2 Governance Registry server can run on a Linux Server.
2. Install Microsoft Visual Studio. Please read more information on installing Microsoft Visual Studio 2010.
Info
This sample of WSO2 Governance Registry has been tested on Microsoft Visual Studio 2010, but also applies to other versions of the IDE.
We assume that you already have added or imported a few WSDLs in WSO2 Governance Registry installation. See Managing WSDLs to learn more on how you could upload or import WSDL files into Governance Registry.
Info
In this example, we have imported the SimpleStockQuoteService.wsdl into WSO2 Governance Registry.
Steps to setup the connection
1. Launch Visual Studio and create a new Console Application
.
2. Right-click on the References
section and select Add Service Reference
.
3. Click on the Advanced
button on the Add Service Reference
dialog box.
4. In the Service Reference Settings
screen select Add Web Reference
.
5. In the Add Web Reference
dialog box, type the Management Console URL (in our example we have used https://localhost:9443/carbon
) and click the Go
button.
6. The WSO2 Governance Registry homepage opens within Visual Studio.
Notice
A situation may occur in which Visual Studio displays an insecure connection message, requiring the user's confirmation to proceed.
The WSO2 Governance Registry Management Console is based on HTTPS protocol, which is a combination of HTTP and SSL protocols. This protocol is generally used to encrypt the traffic from the client to server for security reasons. The certificate with which it works is used for encryption purposes only and does not verify the server's identity. So, when users try to access the WSO2 Governance Registry Management Console, they may receive a warning that they are trying to connect to an untrusted connection. In order to continue working with this certificate, you must "accept" the certificate before access to the site is permitted. Please note that an insecure connection warning may be displayed every time the server is accessed.
This scenario is suitable for testing purposes or for running the program on a company's internal networks. But in cases where there is a need to provide an interface to the outside world, a company should obtain a certificate signed by a well-known CA. The role of a CA is to verify that the server accessed actually has the name by which it is accessed and that this server actually belongs to the given organization.
7. Once you have established a connection to the WSO2 Governance Registry, you will be prompted for a "Username" and "Password." Type in default "admin" as the "Username" and "admin" as the "Password." Click "Sign-in."
8. This should bring up the bring up the home screen of the WSO2 Governance Registry Management Console.
Notice
A situation may occur in which Visual Studio appears to hang while trying to search for Web Services.
The embedded browser of Microsoft Visual Studio has been specifically designed to search for Web Services deployed on remote web sites. However, the process of searching can take longer than anticipated and can become frustrating to a user. If such happens, please click on the Stop
button, which will make the current page load almost instantly.
Visual Studio might also present you with error messages asking your consent on running scripts.
Please click on Yes
if prompted. The embedded browser of Microsoft Visual Studio is not as advanced as a typical web browser that you find today, and might run into difficulties when running complex Java Scripts. Our use of the WSO2 Governance Registry through Visual Studio does not require these scripts to run, and so it is safe to continue despite some script errors.
Please note that you might have to repeat one or both of these steps while following the rest of these guidelines.
9. Navigate to the WSDL List page and select the SimpleStockQuoteService.wsdl file to open it in the Resource Browser.
10. Expand the metadata section after the page has completely loaded.
11. Right-click on the HTTP
permalink and select Copy Shortcut
.
12. Replace the URL
by clicking on it to selecting it, then right-clicking and finally selecting Paste
.
13. Click to Go
button to open the WSDL within the embedded browser of Microsoft Visual Studio.
14. Visual Studio will present you with a security challenge when accessing the permalink requiring you to provide your credentials. Type in default "admin" as the "Username" and "admin" as the "Password." Click the OK
button.
Notice
Microsoft Visual Studio will prompt you with a warning on your credentials being forwarded to the server via clear text. Click Yes
to ignore (or read below on how to avoid this check). You also might be requested to provide your credentials again.
The WSO2 Governance Registry uses HTTP Basic Authentication between client and server when you are using HTTP and HTTPS permalinks. If it is a risk to provide your credentials to access these resources please consider granting anonymous read permissions to the WSDL resource and its dependencies. See Managing Role Permissions for more information on how grant READ
access to wso2.anonymous.role
.
15. Microsoft Visual Studio will now complete discovering the Web Service. Click the Add Reference
button to complete the operation.
16. The Web Reference
should now be added to your project in Microsoft Visual Studio.
17. Double-click on the name of the Web Reference to open it and start working with it in your .NET application. The name is WebReference in this case.
Info
You can repeat the same steps to add more Web Service clients. Please note that the same steps can be followed for projects of types other than Console Application
and we have taken it only as an example.