Complete Generated Code Sample
The following sample shows the all of the C# code used in
Generating a C# Client Code in Visual
Studio but does not attempt to depict the end-to-end actions needed to create an executable:
using System;
using webMethods.ClientAPI;
namespace Pub.String
{
/// <summary>
/// Sample client demonstrating invocation of the 'concat' Integration ///
Service using an object generated by the webMethods Visual
/// Studio Add-in.
/// </summary>
class ClientSample2
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// execute the generated service object
String result = concatStrings( "testString1", "testString2" );
Console.WriteLine( "concat=" + result );
}
/**
* Concatentate strings using the Add-in generated class for the
* pub.strings:concat service
*/
public static String concatStrings( String string1, String string2 )
{
String returnString = null;
// create our connection context with the Integration Server
Context serverContext = new Context();
// connect to the server
try
{
serverContext.connect( "localhost:5555", "Administrator", "manage" );
}
catch( Exception ex )
{
Console.WriteLine("Connection to server failed, reason=" + ex );
return null;
}
// create the Concat service object
//(created by the Add-in for the pub.string:concat service)
Concat concatService = new Concat();
// populate the inputs
concatService.in_inString1 = string1;
concatService.in_inString2 = string2;
// invoke the service
concatService.invoke( serverContext );
// extract the output
returnString = concatService.out_value;
// disconnect from the server
serverContext.disconnect();
return returnString;
}
}
}