sweet_babylhyn
April 21st, 2009, 03:47 AM
I have a confusion guys, are WebServices runs only in server side?
|
Click to See Complete Forum and Search --> : WebService sweet_babylhyn April 21st, 2009, 03:47 AM I have a confusion guys, are WebServices runs only in server side? Shuja Ali April 21st, 2009, 04:10 AM Web Service runs on a Server and has Web Methods that are executed on the server. What is the confusion? sweet_babylhyn April 21st, 2009, 07:06 PM Ok thanks, I think it runs in client and server side depending to the set-up of the developer. So it safe if I will code my connection string of my database into web service.? Alsvha April 22nd, 2009, 01:27 AM The webservice does run server side, and replies with XML (SOAP) via the webmethod calls Shuja Ali mentiosn. Therefore the client can't see what is going on in the webservice and you can safely allow the webservice access to your connection string. sweet_babylhyn April 22nd, 2009, 03:10 AM I see, so the web service creates an xml output going to the client... How about the soap xml below, can I manipulate it in my web form and pass to the web service? How can I change its Content-Length?...Sorry guys, I have a big confusion about soap. Its my first time to code ASP.Net. I already output to the client my database using webmethod. POST /MyWebService/Service.asmx HTTP/1.1 Host: localhost Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://localhost:1563/MyWebService/GetTableValue" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetTableValue xmlns="http://localhost:1563/MyWebService" /> </soap:Body> </soap:Envelope> *********************************************************** HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetTableValueResponse xmlns="http://localhost:1563/MyWebService"> <GetTableValueResult> <ResourceValues> <ResourceID>string</ResourceID> <Plant_PMin>decimal</Plant_PMin> <Plant_PMax>decimal</Plant_PMax> <Mean>decimal</Mean> <SD>decimal</SD> </ResourceValues> <ResourceValues> <ResourceID>string</ResourceID> <Plant_PMin>decimal</Plant_PMin> <Plant_PMax>decimal</Plant_PMax> <Mean>decimal</Mean> <SD>decimal</SD> </ResourceValues> </GetTableValueResult> </GetTableValueResponse> </soap:Body> </soap:Envelope> Shuja Ali April 22nd, 2009, 03:44 AM How about the soap xml below, can I manipulate it in my web form and pass to the web service? I do not understand what you mean by this. This XML would be returned by the Web Service and you can use it in your Web Form. What is it that you want to pass back to Web Service? Also please understand, that while writing Web Services, you don't have to worry about how SOAP works (although it helps if you know it, but it is not a pre-requisite). You can write a Web Method that returns a DataSet and then in your client app you can use the dataset like any other dataset that you create locally. sweet_babylhyn April 22nd, 2009, 03:55 AM ah ok, but it is possible to pass an xml file which contain records into webservice and the webservice will automatically save it into my database table? (Can use also update, delete or retrive data in database and return its output into xml file). Do you have any idea to do this... Shuja Ali April 22nd, 2009, 05:32 AM Yes it is possible to pass XML to the web service. The basic concept of web services runs on top of XML so you should be ok with passing XML to your web service. sweet_babylhyn April 22nd, 2009, 07:13 PM I can pass dataset easily, I used the code below but when I try to pass xml file, it return me an error. <WebMethod()> _ Public Function GetDatasetSet() As DataSet Dim DTFinal As New DataTable Dim DSFinal As New DataSet Dim cnn As String = "DATA SOURCE=192.168.0.10:80;USER ID=uid;password=pwd" Dim oraCnn As New OracleConnection(cnn) Dim oraCmd As New OracleCommand("SELECT * FROM table1") Dim adapter As OracleDataAdapter Try oraCnn.Open() oraCmd.Connection = oraCnn adapter = New OracleDataAdapter(oraCmd) adapter.Fill(DTFinal) Catch ex As OracleException MsgBox("Can not Connect to the Datatabase", MsgBoxStyle.Critical, "Check Connection") Throw Finally oraCnn.Close() End Try DSFinal.Tables.Add(DTFinal) Return DSFinal End Function This comes an error... <WebMethod()> _ Public Function GetXML(byval tmpXML as XML) As XML ........ ......... ......... return FinalXML end function Do you have any suggestion or much better ideas... BTW, I used framework 2.0 Thanks Alsvha April 23rd, 2009, 03:55 AM What error do you get? And FYI, you should edit your post and remove the IP address from your connection string to not display what IP/Port number you use. sweet_babylhyn April 23rd, 2009, 04:17 AM hmmm! If I pass an xml file, do I have to use this ... public function PassXML(byval objXML as XmlDocument) as aXmlDocument I have a difficulty in XML manipulation because the XML will be created during runtime and it will not save in hardrive. Once it created, it will pass to the webservice to manipulate and return new xml which again not save in hardrive. I can serialize and deserialize xml if I will save/get it to hardrive but I hard time if I will do it in runtime without saving it to disk... Do you have any idea to do this?... I searched already in net but all of my example manipulate the xml coming from hardrive. Shuja Ali April 23rd, 2009, 02:41 PM You can pass XML as a string to the Webservice. This is the simplest way of doing it. Something like this <WebMethod()> _ Public Function GetXML(ByVal tmpXML as String) As String ........ ......... ......... return FinalXML end function sweet_babylhyn April 23rd, 2009, 07:21 PM Thanks for your reply and I will give my feedback when it done. sweet_babylhyn April 24th, 2009, 12:55 AM It works already.... Another question, how can I get the method request by the client if it is POST or GET. I want to use REST in my webservice. http://www.parts-depot.com/parts/00345 it will return to the client the details about "00345" <?xml version="1.0"?> <p:Part xmlns:p="http://www.parts-depot.com" xmlns:xlink="http://www.w3.org/1999/xlink"> <Part-ID>00345</Part-ID> <Name>Widget-A</Name> <Description>This part is used within the frap assembly</Description> <Specification xlink:href="http://www.parts-depot.com/parts/00345/specification"/> <UnitCost currency="USD">0.10</UnitCost> <Quantity>10</Quantity> </p:Part> Shuja Ali April 24th, 2009, 03:12 PM You should go through this tutorial, it will help a lot in the long run http://www.codeproject.com/KB/architecture/RESTWebServicesPart2.aspx codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |