The Code Project - Publish, Discover and Invoke Web Services using SOAP and UDDI - C# WebServices: "Invoking the web service: Now we'll invoke the web service method using the SOAP SDK provided by Microsoft. Invoking services using SoapClient(n) class is fairly easy. Here n means the major version appended to the classes. this number is not associated with SOAP SDK's previous versions than 3.0. MSSoapInit method in SoapClient(n) class initialises the web service for the given WSDL and accepts service name and service port.
private void invoke_Click(object sender, System.EventArgs e))
{
SoapClient30 sc = new SoapClient30();
string translateText=textToTran.Text;
string wsdl=null;
try
{
if(wsUri==null)
throw new Exception('Please Discover the service first');
if((new Regex('(wsdl)$')).IsMatch(wsUri))
//check if it's the real WSDL
wsdl=wsUri;
else
wsdl=wsUri+'?wsdl'; //otherwise append WSDL to the service
sc.MSSoapInit(wsdl, 'piglatin', 'piglatinSoap','');
//specify the service name and port name
Type type =sc.GetType();
object []args = {translateText}; //specified service accepts
//just one argument (textToTranslate)
Response.Write('Invoking method using MS SOAP SDK ...');
object ox = type.InvokeMember('toPigLatin',
BindingFlags.InvokeMethod,null,sc,args); //Dynamic Invocation No
//Proxy class, no web reference
Response.Write('Translated String '+ox.ToString());
}
catch(Exception sEx){Response.Write('Exception occurred '+
sEx.Message);}}}"
The more I read, the more I acquire, the more certain I am that I know nothing. -Voltaire
Subscribe to:
Post Comments (Atom)
Ramadan - What is it?
Ramadan is one of the most important and holy months in the Islamic calendar. It is a time of fasting, prayer, and spiritual reflection fo...
-
ZipStudio - A versatile Visual Studio add-in to zip up Visual Studio solutions and projects - The Code Project - C# Programming
-
TargetProcess - Agile Project Management & Bug Tracking Software | Download (Project Management Software, Project Tracking, Bug Tracking...
No comments:
Post a Comment