Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Soap and webservices

Status
Not open for further replies.

andyUK

Programmer
Dec 19, 2000
39
0
0
GB
I have a soap document(XML) for a specific webservice. how do i send the xml document to the webservice using c#?

thanks in advance

Andrew
 
You can send it as any other primitive objects. Here is an example using a DataSet object.
From a web form or a windows application form a XML file is sent to a web service, it modify it depending on business logic and send it back to the client.
Code:
//1. Let be a service named GBTestXML

[WebService(Namespace="[URL unfurl="true"]http://localhost/GBTestXML/")[/URL]]
public class TestXMLSer : System.Web.Services.WebService
{

	[WebMethod (Description="Process DS")]
		public DataSet TestDS(DataSet ds)
		{
			// Alter the received DataSet 
			ds.Tables[0].Rows[1]["firstname"]="Blablabala";
			// Send Back the DataSet
			return  ds;
		}
}
//2. Add the GBTextXML web service as Reference in your web form application or windows form application.
//3. Let be "Button1" a button on the form and the next handler will pass a XML file to the GBTextXML service and the service returns some data.
public class WebForm1 : System.Web.UI.Page
{
	protected System.Web.UI.WebControls.Button Button1;
	private void Button1_Click(object sender, System.EventArgs e)
		{
			DataSet ds = new DataSet();
			ds.ReadXml("myfile.xml");
			TestXMLSer ser = new TestXMLSer ();
			ds = ser.TestDS(ds);
                        ds.WriteXml("myfile.xml");
                        //
			


		}

}
-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top