You want to create a service proxy in C# with more control over the generation than Visual Studio web references give you.
wsdl.exe from the command line and supply the
parameters you want.
Adding a web reference doesn’t afford any customizations on how the WSDL is handled during proxy generation. You may want to change the name of the service as your client application 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.
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).
Example 12-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> </types> <message name="add"> <part name="parameters" element="tns:add" /> </message> <message name="addResponse"> <part name="parameters" ...