NetTalk Central

Author Topic: NetWebServiceMethod  (Read 1474 times)

rupertvz

  • Sr. Member
  • ****
  • Posts: 338
    • View Profile
    • Email
NetWebServiceMethod
« on: April 30, 2026, 01:09:47 PM »
Hi Guys,

I'm working with NetTalk WebServer and using a NetWebServiceMethod procedure.

I can successfully call the endpoint and the procedure executes, but I'm struggling to get a JSON response to return in the browser. Currently, the request runs, but the response is blank when JSON is selected.

I have:

A queue defined for return (Q)
JSON enabled in the template
ServiceMethod populating the queue

However, it seems like the JSON branch in BuildResult / BuildResultFields is not being generated or executed.

My questions:

Is there a recommended example app or webinar showing a working NetWebServiceMethod returning JSON?
Should JSON responses for queues be handled purely via template, or is manual handling (e.g. AddJSONFromQueue) expected?
Is there a standard pattern for returning simple JSON (without queues)?

Any guidance or working example would be appreciated.
« Last Edit: May 03, 2026, 09:30:43 AM by rupertvz »

seanh

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
    • Email
Re: NetWebServiceMethod
« Reply #1 on: April 30, 2026, 06:24:55 PM »
have you set the content type?
net.ContentType = 'application/json'

Jane

  • Sr. Member
  • ****
  • Posts: 426
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: NetWebServiceMethod
« Reply #2 on: April 30, 2026, 09:17:53 PM »
Are you trying to send JSON to a web browser or to a client of some sort?

There's a NetTalk example WebServiceRequiresXFiles (77) that includes two apps - a client and a web server.

It's also often useful to use the netdemo example program as a web client to debug what you're doing.

rupertvz

  • Sr. Member
  • ****
  • Posts: 338
    • View Profile
    • Email
Re: NetWebServiceMethod
« Reply #3 on: Today at 08:20:40 AM »
Thanks for the suggestion Sean,

I did try to force JSON via ContentType, but I ran into compile issues ? it seems like setting ContentType directly (e.g. net.ContentType or p_web.ContentType) is not available in a NetWebServiceMethod.

From what I understand, NetTalk should handle the response format via template settings or request negotiation.

I also tested:
http://127.0.0.1:88/TestFileParameter?_json_=1

But the response still comes back as XML.

Is setting ContentType manually actually supported in this context, or should JSON output be controlled purely via the template and request?

rupertvz

  • Sr. Member
  • ****
  • Posts: 338
    • View Profile
    • Email
Re: NetWebServiceMethod
« Reply #4 on: Today at 08:22:05 AM »
Thanks Jane, that makes sense regarding using the client.

At the moment I'm testing directly in the browser just to validate the behaviour of the template.

I'm using the TestFileParameter method from Example 77 with:

Return Type = View
View Table = Customer

However, even with data in the Customer table, the response is empty:
<TestFileParameter_response></TestFileParameter_response>

So I'm trying to confirm:

Should this example return Customer records without additional parameters?
Does the VIEW require specific parameters or filters to trigger data retrieval?

Also, even when I add _json_=1 to the URL, the response remains XML ? so I'm trying to understand whether that's expected when using a browser, or if something in my configuration is missing.

I'll test with a client as suggested, but I'd like to first confirm the expected behaviour of the example itself.
« Last Edit: Today at 08:24:29 AM by rupertvz »