Friday, October 3, 2008

Consuming Composite Web Service

If anyboy is having problems with Composite Web Services?
here is the code for accessing the Web Service craeted using Composite Studio.
Add a web reference in VS 2005 to the Web site you have created:
http://myserverip:1100/myServices/WSvTBLAPPLNCountry?wsdl

Copy/ paste the code below either in the page_load or button click event:

#region PopulateCountry
{
SVcCOUNTRY objCountry = new SVcCOUNTRY();
CountryyWebReference.Svc_ApplnCountry objgeorefcountry = new Svc_ApplnCountry();
string CONNSTRING = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
DataSet ds = new DataSet();
NetworkCredential nc = new NetworkCredential("myusername", "mypaswd", "");
objgeorefcountry.Credentials = nc;
CountryyWebReference.VwCountryRow objCountryRow = new VwCountryRow();
CountryyWebReference.VwCountryResponse objresponse = objgeorefcountry.VwCountry(objCountryRow);
CountryyWebReference.VwCountryResponse objres= objcountry.VwCountry(objCountryRow);
DataTable dt = new DataTable();
ArrayList arryLstCountry = new ArrayList();
for(int i = 0; i < objresponse.VwCountry.Length;i++)
{
arryLstCountry.Add(objresponse.VwCountry[i]);
}
dgrdCountry.DataSource = arryLstCountry;
dgrdCountry.DataBind();
}
catch (Exception expd)
{
lblError.Text =expd.Message + " " + expd.StackTrace;
}
}
#endregion PopulateCountry

No comments: