I have a confusion guys, are WebServices runs only in server side?
Printable View
I have a confusion guys, are WebServices runs only in server side?
Web Service runs on a Server and has Web Methods that are executed on the server. What is the confusion?
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.?
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.
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.
Code: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>
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.
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...
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.
I can pass dataset easily, I used the code below but when I try to pass xml file, it return me an error.
Code:<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...
Code:
<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
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.
hmmm! If I pass an xml file, do I have to use this ...
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.Code:
public function PassXML(byval objXML as XmlDocument) as aXmlDocument
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.
You can pass XML as a string to the Webservice. This is the simplest way of doing it. Something like thisCode:<WebMethod()> _
Public Function GetXML(ByVal tmpXML as String) As String
........
.........
.........
return FinalXML
end function
Thanks for your reply and I will give my feedback when it done.
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.
it will return to the client the details about "00345"Code:http://www.parts-depot.com/parts/00345
Code:<?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>
You should go through this tutorial, it will help a lot in the long run
http://www.codeproject.com/KB/archit...icesPart2.aspx