I created a web service and it is working fine my local machine. Now we want to implement it on our project. What we require is:
1] My Web Service reads the Employee Number and it returns his name. Once i publish it, this web service should generate .xml file. So that we can access this on other platform(such as : Andriod)
I don't know how to do this. Please guide me for this.
As per my opinion use Type data set is best option because after fill data set you can generate xml file very easily add new item and select type dataset (xsd) file
Here is benefit of Type dataset
You can fill as many table as you want multi table
If you can use WCF to build the webservice, then I'd strongly recommend you create it as a WCF REST service. The REST programming model can help you define service operations that can be called through simple and standard HTTP GET/POST request.
For your case, you want to expose some Xml format data to client (either .NET or java/android), you can define a service operation which return a XElement object(which contains the XML data you want to return). e.g.
[ServiceContract]
public interface ISimpleRESTService {
......
[WebGet]
[OperationContract]
XElement GetXmlData();
}
public class SimpleRESTService : ISimpleRESTService
{
......
public XElement GetXmlData()
{
var elm = XElement.Parse(
@"<dataRoot>
<items>
<item id='1'>item 1</item>
<item id='2'>item 2</item>
<item id='3'>item 3</item>
</items>
</dataRoot>");
return elm;
}
}
then, you can directly invoke the operation in web browser or use strong-typed client(as long as it support sending HTTP get/post requests).
Here are some web articles on consuming REST service from windows phone 7 client and android client:
Your code helped me to create .xml file on the server and i got every records in it.
Now my next question is, if I pass Roll Number then it returns me Student Name and for that I wrote a web service. But can i generate .xml file for the partucular student which generated? When we add reference of the web service during that
it displays the student name in .xml format. something like that...
Silverlight....
Member
431 Points
369 Posts
Regarding generating .xml file
Apr 30, 2012 03:23 AM|LINK
Hi All,
I created a web service and it is working fine my local machine. Now we want to implement it on our project. What we require is:
1] My Web Service reads the Employee Number and it returns his name. Once i publish it, this web service should generate .xml file. So that we can access this on other platform(such as : Andriod)
I don't know how to do this. Please guide me for this.
Thanks.
Bhavik Solu...
Member
746 Points
159 Posts
Re: Regarding generating .xml file
Apr 30, 2012 05:17 AM|LINK
As per my opinion use Type data set is best option because after fill data set you can generate xml file very easily add new item and select type dataset (xsd) file
Here is benefit of Type dataset
Code for generate xml
Steven Cheng...
Contributor
4187 Points
547 Posts
Microsoft
Moderator
Re: Regarding generating .xml file
May 01, 2012 03:11 AM|LINK
Hi,
If you can use WCF to build the webservice, then I'd strongly recommend you create it as a WCF REST service. The REST programming model can help you define service operations that can be called through simple and standard HTTP GET/POST request.
#An Introduction To RESTful Services With WCF
http://msdn.microsoft.com/en-us/magazine/dd315413.aspx
#WCF Web HTTP Programming Model Overview
http://msdn.microsoft.com/en-us/library/bb412172.aspx
#WCF REST Service Template 40(CS)
http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd
For your case, you want to expose some Xml format data to client (either .NET or java/android), you can define a service operation which return a XElement object(which contains the XML data you want to return). e.g.
[ServiceContract] public interface ISimpleRESTService { ...... [WebGet] [OperationContract] XElement GetXmlData(); } public class SimpleRESTService : ISimpleRESTService { ...... public XElement GetXmlData() { var elm = XElement.Parse( @"<dataRoot> <items> <item id='1'>item 1</item> <item id='2'>item 2</item> <item id='3'>item 3</item> </items> </dataRoot>"); return elm; } }then, you can directly invoke the operation in web browser or use strong-typed client(as long as it support sending HTTP get/post requests).
Here are some web articles on consuming REST service from windows phone 7 client and android client:
#Consuming WCF 4.0 REST Service in Windows Phone 7
http://www.dotnetcurry.com/ShowArticle.aspx?ID=501
#Calling a REST web service from Android
http://timewasted.net/?p=127
Feedback to us
Microsoft One Code Framework
Silverlight....
Member
431 Points
369 Posts
Re: Regarding generating .xml file
May 01, 2012 12:00 PM|LINK
Hi Bhavik,
Your code helped me to create .xml file on the server and i got every records in it.
Now my next question is, if I pass Roll Number then it returns me Student Name and for that I wrote a web service. But can i generate .xml file for the partucular student which generated? When we add reference of the web service during that it displays the student name in .xml format. something like that...
thanks
Silverlight....
Member
431 Points
369 Posts
Re: Regarding generating .xml file
May 01, 2012 05:46 PM|LINK
I just change my select * query and execute the query
many thanks to all