Java

If you are writing your client code in Java, we recommend that you use the open source SOAP engine/framework called Axis to generate proxy client code for the Bisgateway web services. This recommendation is for all services except the Annual Report PDF service, which uses SOAP attachments. For this web service we have included an entire code example with client code that can be used to call this service.Please refer to http://ws.apache.org/axis/ for more information about Axis and to download the latest version.

Generating Java Client Code with Axis
In Axis there is a tool called WSDL2Java that can be used to generate Java client stub code from a web service WSDL file. To use this tool you just run it with java from the command prompt:

java org.apache.axis.wsdl.WSDL2Java -a <WSDL URL>

Please notice that you must have java.exe in your path before running this and that all jar files used by Axis (found in the lib directory under your Axis installation directory) must be in your classpath before you can use the command above.
If successful the command above should result in a lot of new java classes being created for you. If we run this command with the NRG Consumer Search WSDL file as an input parameter then the following classes and interfaces should be generated:

  • NRGConsumerSearchLocator.java
  • NRGConsumerSearchSoapBindingStub.java
  • BRGService.java
  • NRGConsumerSearch.java
  • NRGConsumerSearchRequest.java
  • Criteria.java
  • NRGConsumerSearchResponse.java
  • Consumer.java
  • BRGFault.java
  • ToCountry.java
  • UserId.java
  • UserPassword.java
  • CustomerCode.java
  • CustomerCodeOwner.java
  • FromCountry.java
  • IncludeEmptyFields.java
  • Language.java
  • TimeTaken.java

This might seem like a lot of classes, but don’t worry too much about what they do right now. Please see Using the generated code section below for an example on how to use the generated code.
WSDL2Java have a lot of optional parameters that can be used to specify which java package you want the generated code to be placed in, which directory they should be placed under etc. Please refer to the Axis user guide at http://ws.apache.org/axis/java/user-guide.html for a complete documentation on WSDL2Java.

Using the Generated Code

After you have generated client code with Axis you probably want to use the code. Here you will find a basic example code that shows how to use the Axis generated client code to perform a consumer search (please see the NRG Consumer Search section below for further information about this web service).

Client Code to Annual Report PDF

The following example code can be used when calling the Annual Report PDF service in the Bisgateway. This code uses a javax.activation.DataHandler, which holds the PDF file. It also uses SOAP with Attachments API for Java (SAAJ) and commons-httpclient 2.0 from Apache which can be downloaded at http://jakarta.apache.org/commons/httpclient/. Note: This code will be distributed as a ready-to-use component in the download section.

.Net

Here follows an example on how to build your client using the Microsoft .Net framework. The code example is given in C# but it could easily be changed into VB.Net.

Generate a Proxy in .Net

The .Net SDK contains a tool called wsdl.exe that can be used to generate client proxy code from the WSDL-file of any web service.

To use the tool you just type:

wsdl /l:CS /protocol:SOAP <WSDL URL>

into a Visual Studio Command Prompt. If you do this on the Consumer Search service WSDL for example it should generate a source file called NRGConsumerSearch.cs.

You can also use the Add Web Reference functionality in Visual Studio which will let you add a web service reference to your project by simply pointing out a WSDL file. This action will also generate client proxy code, much like above. Please refer to the Microsoft Visual Studio documentation for more information about how to do this.

Using the Generated Code

The following example shows how to use the generated proxy code.

 

Business Support 36 73 81 84
Monday-Thursday kl. 08:30-16:00 Friday kl. 08:00-15:30. Click here for Business Support
© Soliditet 2014. All Rights Reserved