|
-
April 21st, 2009, 03:47 AM
#1
WebService
I have a confusion guys, are WebServices runs only in server side?
-
April 21st, 2009, 04:10 AM
#2
Re: WebService
Web Service runs on a Server and has Web Methods that are executed on the server. What is the confusion?
-
April 21st, 2009, 07:06 PM
#3
Re: WebService
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.?
-
April 22nd, 2009, 01:27 AM
#4
Re: WebService
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.
-
April 22nd, 2009, 03:10 AM
#5
Re: WebService
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>
-
April 22nd, 2009, 03:44 AM
#6
Re: WebService
 Originally Posted by sweet_babylhyn
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.
-
April 22nd, 2009, 03:55 AM
#7
Re: WebService
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...
-
April 22nd, 2009, 05:32 AM
#8
Re: WebService
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.
-
April 22nd, 2009, 07:13 PM
#9
Re: WebService
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
Last edited by sweet_babylhyn; April 23rd, 2009 at 04:02 AM.
-
April 23rd, 2009, 03:55 AM
#10
Re: WebService
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.
-
April 23rd, 2009, 04:17 AM
#11
Re: WebService
hmmm! If I pass an xml file, do I have to use this ...
Code:
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.
-
April 23rd, 2009, 02:41 PM
#12
Re: WebService
You can pass XML as a string to the Webservice. This is the simplest way of doing it. Something like this
Code:
<WebMethod()> _
Public Function GetXML(ByVal tmpXML as String) As String
........
.........
.........
return FinalXML
end function
-
April 23rd, 2009, 07:21 PM
#13
Re: WebService
Thanks for your reply and I will give my feedback when it done.
-
April 24th, 2009, 12:55 AM
#14
Re: WebService
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.
Code:
http://www.parts-depot.com/parts/00345
it will return to the client the details about "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>
-
April 24th, 2009, 03:12 PM
#15
Re: WebService
You should go through this tutorial, it will help a lot in the long run
http://www.codeproject.com/KB/archit...icesPart2.aspx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|