Java Reference
In-Depth Information
Creating a .NET Web Service Client in C#
Problem
You want to create a service proxy in C# with more control over the generation than Visual
Studio web references give you.
Solution
Use wsdl.exe from the command line and supply the parameters you want.
Discussion
Adding a web reference doesn't afford any customizations on how the WSDL is handled dur-
ing proxy generation. You may want to change the name of the service as your client applic-
ation will use it, or you may want to output the proxy in a language other than C# (such as
VB.NET). Let's first walk through a simple example of invoking a Java-based web service.
NOTE
This example will work with any WSDL, but the specifics are addressed as if you have deployed a
calculator web service that adds two numbers together and returns a sum. There's a similar example
in the NetBeans 6.1 samples that you can easily deploy locally.
Example 12-7 shows basic WSDL from the NetBeans 6.1 sample that represents the adding
service you're going to call (I've modified it slightly to keep it small).
Example12-7.Calculator.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<definitions ...
targetNamespace="http://calculator.me.org/"
name="CalculatorWSService">
<types>
<xsd:schema>
<xsd:import namespace="http://calculator.me.org/"
schemaLocation="http://localhost:8080/CalculatorApp/
CalculatorWSService?xsd=1">
</xsd:import>
</xsd:schema>
Search WWH ::




Custom Search