Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hai all,

 

i developed a webservice which will take the data and update the database here my doubt which url i will provide to the client when i run my service my URL Looks like this http://localhost:2412/test/Service.asmx in the browser it shows two links named as helloworld and response i wrote code in response. so here i am unabe find which url i have to provide to the client please guide me here i am giving link after clicking the response link my url look like this http://localhost:2412/test/Service.asmx?op=response please help me its urgent

Posted

You cannot give somebody the URL of the web service that is running locally in your copy of Visual Studio.

 

After you publish the website your web server, your URL should look something like this:

 

http://webservices.mywebserver.com/test/Service.asmx

 

This is the URL you should give to your client -- they will then be able to access all the functions available in the service.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted

Browser vs code

 

Viewing your web service in a browser is quite different from using it in code. When your web service is accessed in code, the request will be posted to the Service.asmx URL whether the client is calling 'helloworld' or 'response'. The details of which web method the client is calling, along with any parameters being passed in, are contained in the HTTP POST data which is sent to the web server.

 

Basically, you only need to use the URL of the Service.asmx page, and from that clients will be able to access all the functions provided by that service.

 

Good luck :cool:

Never trouble another for what you can do for yourself.
Posted
You could add a WinForms app to your solution and add a "web reference" to the web service, and then in your WinForms app you could consume the web service to ensure that it is working as expected.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted (edited)

Hai i have developed an web service and i am testing it by calling like this

it is giving an Error 500 Remoteserver returned an error the calling code as follows please help how to solve

 

Dim Request As WebRequest = WebRequest.Create("http://156.11.127.18/test/Service.asmx")
Request.Method = "POST"
       Dim PostData As String = "<response><TransactionId>12</TransactionId><VendorTransactionId>13</VendorTransactionId></response>"
Dim ByteArray As Byte() = Encoding.UTF8.GetBytes(PostData)
       Dim Instance As New WebException
       Dim Value As WebExceptionStatus
Request.ContentType = "application/x-www-form-urlencoded"
       'Request.ContentType = "XML"
       ' Set the ContentLength property of the WebRequest.
       Request.ContentLength = ByteArray.Length
       ' Get the Request stream.
       Dim dataStream As Stream = Request.GetRequestStream()
       ' Write the data to the Request stream.
       dataStream.Write(ByteArray, 0, ByteArray.Length)
       ' Close the Stream object.
       dataStream.Close()
       ' Get the response.
       Value = Instance.Status
       Dim response As WebResponse = Request.GetResponse()
       ' Display the status.
       Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
       ' Get the stream containing content returned by the server.
       dataStream = response.GetResponseStream()
       ' Open the stream using a StreamReader for easy access.
       Dim reader As New StreamReader(dataStream)
' Read the content.
       Dim responseFromServer As String = reader.ReadToEnd()

       TextBox1.Text += responseFromServer

       ' Clean up the streams.
       reader.Close()
       dataStream.Close()

Edited by PlausiblyDamp
  • Administrators
Posted

Off the top of my head it looks as though you are sending the request to the webservice without specifying which web method should handle it.

 

Did you try adding a web reference though like Nate Bross suggested? It would be far easier to do it that way...

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Ya i tried by adding the webmethod it is working fine but the string i provided is TramsactionID=string&VendorID=string& and so on, but i want to send data as<TransactionID>string</TransactionID><VendorID>string</vendorID> like this i want to send if i am trying this i am getting an protocolvoilation error

my webmoethod is as follows

 

<webmethod()>public function resp(Byval TransactionID as String,Byval VendorID as String) as string

 

dim a as string = TransactionID

dim b as string = VendorID

 

after this databaseupdation coding

 

so any changes in my webmethod to accept the data as xmlString format

please guide me if it works with the .NET Client then i have to test with JAVA Client

Posted

If you have added a web method to your client project, you do not need to pass the values as XML -- the framework will serialize your method call and send it to the web service.

 

If this is your WebService

<webmethod()>public function resp(Byval TransactionID as String,Byval VendorID as String) as string

dim a as string = TransactionID
dim b as string = VendorID


return x
end function

 

After adding the WebService as a "Web Reference" to your client project, you can call it like this. After you import the namespace and define the object

 

Sub Button_Click(Sender as Object, e as EventArgs)
  Dim objWebService = new com.site.webservice.YourWebServiceClass()
  MessageBox.Show(objWebService.resp("myTransID", "myVendorID"))
End Sub

 

What does your client code look like?

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted
thank you i did testing by adding the webreference to my windowsform and try your cod it is working fine. but when i have this url for testing wiht java client, i don't know what is theire code but they said that they are sending the data by using post method. while they are testing they are getting error like this (500 Request format is invalid: text/xml) what should i suggest to clear this error please guide me. they can see my webserive in theire browser and if they are trying by post the data using invoke method it is working fine. the data they providing like this (<TransactionId>123456</TransactionId><VendorTransactionId>110</VendorTransactionId>) so please tell me what to do i struck up my work because of this

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...