Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other
Go Back  Xtreme Visual Basic Talk > > > Difficulty getting a REST client and server to "see" each other


Reply
 
Thread Tools Display Modes
  #1  
Old 11-24-2014, 03:59 PM
VisualaBasikka VisualaBasikka is offline
Centurion
 
Join Date: Oct 2004
Posts: 130
Default Difficulty getting a REST client and server to "see" each other


With SOAP you would use "add service reference" but what do you do when it's REST?

And how do I know what the port number after the local host is to be?
Reply With Quote
  #2  
Old 11-24-2014, 04:38 PM
PlausiblyDamp's Avatar
PlausiblyDampDifficulty getting a REST client and server to "see" each other PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

REST generally doesn't have the same approach as SOAP to these things. SOAP provides a lot of additional metadata to allow tools to auto generate classes etc, however this comes at a cost (XML is large and can be very inefficient, Xml schemas can be overly complex and restrictive, SOAP request / response messages are large and complex etc)

REST solves a lot of these problems by being a lot more lightweight (JSON is simpler and easier to process, requests are a simple HTTP GET / POST etc.), this comes at the cost of not having the rich metadata SOAP provides.

If you are connecting to a RESTful service you will generally need to use additional documentation to figure out message formats and URLs.

If you are working with recent versions of .Net then some things to get you started...

JSON.Net (http://james.newtonking.com/json) with a good intro from Scott Hanselman at http://www.hanselman.com/blog/NuGetP...thJsonNET.aspx

http://json2csharp.com/ can generate C# class from JSON (can't find a VB.Net version though)

HttpClient (http://msdn.microsoft.com/en-us/libr...vs.118%29.aspx) with a bunch of examples at http://blogs.msdn.com/b/webdev/archi...t-samples.aspx
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 12-04-2014, 01:27 PM
VisualaBasikka VisualaBasikka is offline
Centurion
 
Join Date: Oct 2004
Posts: 130
Default

I am trying to get the client to call a function from the server. On the server I have this function inside a public module:

Code:
        Public Function test()
            MessageBox.Show("test funtion on server reached.")
            Return vbNull
        End Function
On the client (which is in a separate project) I want to call the function on the server, so I tried this

Code:
test()
But this gives "Error 1 'test' is not declared. It may be inaccessible due to its protection level."

The server itself seems ok, when I run it the command prompt opens and if I go to IE and type in "http://localhost:8080" it seems ok. But I just can't get the client to see the server at all.
Reply With Quote
  #4  
Old 12-04-2014, 02:59 PM
PlausiblyDamp's Avatar
PlausiblyDampDifficulty getting a REST client and server to "see" each other PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

What kind of project is the server portion? How have you linked the client to the server?

I would also be very careful in using something like a MessageBox in a server application as it would normally not have any visible UI for someone to interact with.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #5  
Old 12-04-2014, 03:29 PM
VisualaBasikka VisualaBasikka is offline
Centurion
 
Join Date: Oct 2004
Posts: 130
Default

The messagebox I can easily change but I am using this code in the client to try to connect to the server.

Code:
    Dim strURI As String = "http://localhost:8080/"
            Dim rq As HttpWebRequest
            rq = WebRequest.Create(strURI)  ' GET by default.
Reply With Quote
  #6  
Old 12-04-2014, 04:01 PM
PlausiblyDamp's Avatar
PlausiblyDampDifficulty getting a REST client and server to "see" each other PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Just creating a webrequest object isn't enough, you would actually need to also read from the WebRequest something like
Code:
Dim resp as HttpWebResponse = req.GetResponse()

Dim reader as StreamReader = New StreamReader(resp.GetResponseStream())
Dim result = reader.ReadToEnd()
should do it.

Although if you are doing this kind of thing I would strongly recommend not using HttpWebRequest but the HttpClient I mentioned in my original reply.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other
 
Difficulty getting a REST client and server to "see" each other
Difficulty getting a REST client and server to "see" each other
 
-->