Seite 1 von 1

Invoke SOAP-action from HTML/JavaScript

Verfasst: Do, 13. Dez 2018 20:23
von Stephan Borst
Hi there,

I have a xb2net webserver running on localhost (port 80).
My xbase written client can invoke SOAP-actions on this server.

Now I want to invoke the SOAP-actions from HTML/JavaScript.

So far I have found that I might use a JavaScript which should look like:
(only the relevant part):

var xmlhttp = new XMLHttpRequest();
xmlhttp.open('POST', 'http://localhost:80', true)
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
xmlhttp.setRequestHeader('SOAPAction', '"Here I should specify ny SOAP-action, but which syntax?");
xmlhttp.send( "Here I specify my XML-Request, which I think is ok");

Full example on: https://stackoverflow.com/questions/124 ... ap-example


Anyone any experience with writing such a client ?

Regards, Stephan

Re: Invoke SOAP-action from HTML/JavaScript

Verfasst: Fr, 14. Dez 2018 7:58
von ramses
Hi Stephan

SOAP is the solution for Apps. As you can see in the sample apps in the DEMO directory of xb2net. For Client Apps running in the Web Browser and built with HTML / Javascript, AJAX is better suited and much easier to use. If you need to use SOAP in web apps, e.g. For stock queries in online shops you get from there help which information must be contained in the Header.

Regards Carlo

Re: Invoke SOAP-action from HTML/JavaScript

Verfasst: Fr, 14. Dez 2018 14:14
von Stephan Borst
Hi Carlo,

Thanks for the hint about Ajax.
I searched for some samples and it looks easy.
All examples use something like:

var webserUrl = "http://localhost:62187/SampleService.asmx";

I don't understand the "SampleService.asmx". (Active server Methods).
What to specify for a xbnet-webserver ?

Regards, Stephan

Re: Invoke SOAP-action from HTML/JavaScript

Verfasst: Fr, 14. Dez 2018 14:44
von ramses
Hi Stepan
What to specify for a xbnet-webserver ?
The function name on the xb2net server.

http://192.168.10.200/dispatcher

dispatcher == the Function WEB_dispatcher() on the xb2net Server.

the samples you find on the internet you have to adapt to your own needs. Your example calls on the server for which it was made a script file "SampleService.asmx" this process the request. In xb2net it MUST be the function name without prefix SWEB_ (HTTPS) or WEB_ (HTTP) and not a filename with a dot.

Regards Carlo

Re: Invoke SOAP-action from HTML/JavaScript

Verfasst: Mo, 17. Dez 2018 10:59
von Stephan Borst
Hi,

Thanks for this hint.
I tried to retrieve date/time from my soap-server. This is a SOAP-method which comes standard with
the xb2net-webserver software. See method; PROCEDURE SOAP_GetDateTime( oIn, oOut )

I do see logging in the transaction.log ->
2018-12-17 10:48:43 127.0.0.1 - NgSoapServer.exe DESKTOP-OE1DIA4 127.0.0.1 5242960 OPTIONS /GetDateTime etcetc..

I am surprised not to see "POST" , but instead I see "OPTIONS" ????
In the ajax I did specify type: "POST"
I don't get any date/time response from the server.

I have included my html/ajax/jquery soapclient as an attachment.
All suggestions are welcome.

Regards, Stephan

Re: Invoke SOAP-action from HTML/JavaScript

Verfasst: Mo, 17. Dez 2018 11:07
von AUGE_OHR
hi,

welcome to German Xbase++ Forum

if you have special Question to xb2net ask Author in http://www.xbwin.com/forum.html