Sample code required for a TD API app (webservice)

Post your tools and samples or ask for them.
RGM Software
Canada
Posts: 3
Joined: 12 Oct 2017, 19:55
Location: Toronto, Canada

Sample code required for a TD API app (webservice)

Post by RGM Software » 07 Feb 2020, 03:55

I need some sample TD code to create an API that reads JASON data (such as a part number) and then looks up the part number in a SQLBase table to get the price that is returned. Thank you in advance.

User avatar
H3PO4
Germany
Posts: 265
Joined: 10 Mar 2017, 07:53
Location: Rohlstorf, Germany

Re: Sample code required for a TD API app

Post by H3PO4 » 07 Feb 2020, 06:53

Hi RGM,

could you please tell us the TD version you are developing on?
In version 7.x there are new functions that make REST with JSON much easier.

Regards
Henning

RGM Software
Canada
Posts: 3
Joined: 12 Oct 2017, 19:55
Location: Toronto, Canada

Re: Sample code required for a TD API app

Post by RGM Software » 07 Feb 2020, 13:37

Hello Henning,
Thank you for your reply.
I am using 6.1
Glenn

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 2956
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Sample code required for a TD API app

Post by Dave Rabelink » 10 Feb 2020, 07:51

Just to add some more info on this question after having talked to you on the phone.

Glenn needs info on how to create a webservice (REST or SOAP) using Team Developer which runs on his server.
This webservice connects to SqlBase which stores data given in the webservice API. It processes the data and will return the data back.

The client of the webservice is a website (internally somewhere on the network) which uses the webservice API to pass in the data and receives the response.

If anyone here could provide info, recommendations and any leads to documentation or samples on this scenario please post it here.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

a_sivababu
India
Posts: 521
Joined: 10 Mar 2017, 08:46
Location: Chennai,India

Re: Sample code required for a TD API app

Post by a_sivababu » 10 Feb 2020, 09:00

I am not sure whether I have understood the requirement. but, provided my input here.

If Glenn uses TD 6.1 .NET version then we can go ahead and create web services in SOAP as REST API is not yet supported by them. Steps to create web services

1. Use the team Developer 6.1 .NET version if it is already purchased.
2. Build the Web services and operations from TD 6. .NET. you have samples and DevCon material from TD Wiki from this forum.
3. Build the web services which will create dll and .ASMX file
4. Setup Internet Information Web Server in your server and make sure that the default IIS web site is up and running.
5. Create a folder under wwwroot folder, say soapsample
6. create bin directory under soapsample folder.
7. copy the asmx in soapsample folder and then dll to bin directory. (note- if you have not installed TD in server then you have to copy few .NET dlls from TD directory)
8. open inetmgr of IIS webserver and then navigate to soapsample and then right lick on the folder to say "convert application"
9. you can type this url in your browser like http://machinename:80/soapsample
10. you can see your service operation (say you have created opSoapsample) there if you have deployed it properly.
11. if you have used primitive data type in one of the operation then you can even test that service operation. Complex data type like number, date etc can not be tested there.
12. if everything is fine and the client of the website is also running inside your company (intranet) then you can just share http://machinename:80/soapsample/opsoapsample.asmx. WSDL file provides Request and Response message, Parameters etc which will be verified by client web site.
13. you can also consume back your TD .NET web service back to your TD for just testing purpose. you have sample in TD and also this TD forum with MSXML which is shared by Dave.


If the client web site needs data only in JSON format instead of XML format then i think we have to have TD 7.x for creating web service in JSON format.

Thanks
Siva A

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 1282
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Re: Sample code required for a TD API app (webservice)

Post by Igor Ivanovic » 11 Feb 2020, 09:43

Hi,

Like Siva said , if you want to create a REST web service, you will have to develop it with TD7.x, as the previous versions could create only SOAP web services.
Also TD7.3, being the latest version, have an enhanced SalJSONSerialize/Deserialize functions to easily convert your classes to JSON and viceversa.

Just my 2 cents.
Igor Ivanovic
Image

a_sivababu
India
Posts: 521
Joined: 10 Mar 2017, 08:46
Location: Chennai,India

Re: Sample code required for a TD API app (webservice)

Post by a_sivababu » 11 Feb 2020, 11:09

Hi Igore,
I think TD 7.x is still works only for SOAP web Services but we can return the output in JSON format instead of XML format.

As per my understanding, We can consume REST API or GraphQL services using SalJSONxxxxxx() but Publishing TD coding through REST API or GraphQL is not yet done. Or, I am stupid. :-)

Thanks
Siva A

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 1282
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Re: Sample code required for a TD API app (webservice)

Post by Igor Ivanovic » 11 Feb 2020, 12:42

Hi Siva,

I actually didn't tried to develop the REST service, but all of the TD7.x papers mention REST API this, REST API that, so I assumed that we can build REST web services, not only consume them. It seems that actually I'm stupid assuming that it can be done, not you. :?
Igor Ivanovic
Image

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 2956
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Sample code required for a TD API app (webservice)

Post by Dave Rabelink » 12 Feb 2020, 12:21

Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

User avatar
H3PO4
Germany
Posts: 265
Joined: 10 Mar 2017, 07:53
Location: Rohlstorf, Germany

Re: Sample code required for a TD API app (webservice)

Post by H3PO4 » 13 Feb 2020, 16:07

Hi Igor, hi Siva,

TD7 .NET has a compiler option that enables JSON.

The webservice compiled using that option understands JSON Data sent by the POST protocol and returns data in JSON format, other verbs (e.g. PUT, DELETE) are not supported.

With a TD Client application you can exchange JSON data with the TD.NET webservice using SalJSONDeserializeUDV.

Henning

User avatar
H3PO4
Germany
Posts: 265
Joined: 10 Mar 2017, 07:53
Location: Rohlstorf, Germany

Re: Sample code required for a TD API app (webservice)

Post by H3PO4 » 13 Feb 2020, 19:29

Attached is an example of a TD.NET 7.2 REST Webservice (backportable) with a TD client application.
It is an adapted sample from OpenText for TD Mobile.
It uses the ISLAND database from the standard installation.

Best regards
Henning
TD_JSON_REST_SAMPLE.zip
You do not have the required permissions to view the files attached to this post.

a_sivababu
India
Posts: 521
Joined: 10 Mar 2017, 08:46
Location: Chennai,India

Re: Sample code required for a TD API app (webservice)

Post by a_sivababu » 14 Feb 2020, 08:49

Hi Henning,
Thanks. As you mentioned above, The TD 7.2 .NET ASMX web services is just enabled with JSON format but it is still SOAP only.

I feel Gupta is just reusing SalJSONSerialize/Deserialize for calling their own JSON enabled ASMX SOAP web services through this SAL functions with generic POST method (may be alternative for Axis2c).

Let me test this both ASMX with XML and ASMX with JSON through POSTMAN and SOAPUI web service utility to understand more on this.

AFAIK, Gupta is not yet ready for publishing with REST API and GraphQL. I may be still wrong as I am not clear with their design and work around.

Thanks
Siva A

RGM Software
Canada
Posts: 3
Joined: 12 Oct 2017, 19:55
Location: Toronto, Canada

Re: Sample code required for a TD API app (webservice)

Post by RGM Software » 15 Feb 2020, 15:50

Thanks everyone for your responses. I am trying to work through them to make some progress with my project.
Any continued assistance is appreciated.
Glenn

Return to “Tools & Samples”

Who is online

Users browsing this forum: [Ccbot] and 0 guests