WCF service usage without adding its refrence


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. System.Runtime.Serialization
  2.  
  3. private void button1_Click(object sender, EventArgs e)
  4. {
  5. BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
  6. EndpointAddress endpointAddress = new EndpointAddress("<a href="http://localhost:1031/Service/Person.svc&quot" rel="nofollow">http://localhost:1031/Service/Person.svc&quot</a>;);
  7. IPersonService personService = new ChannelFactory<IPersonService>(basicHttpBinding, endpointAddress).CreateChannel();
  8. Person person = personService.GetPersonData("F488D20B-FC27-4631-9FB9-83AF616AB5A6");
  9. textBox1.Text = Convert.ToString("Name:"+person.FirstName + "\t" + "Last Name:"+person.LastName + "\t" + "Guid:"+person.Guid+"\t"+"Postal Code:"+person.PostalCode+"\t"+"State:"+person.State+"\t"+"City:"+person.City);
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.