Invoke SOAP-action from HTML/JavaScript

Vom Front-End bis SOAP.

Moderator: Moderatoren

Antworten
Stephan Borst
Rookie
Rookie
Beiträge: 12
Registriert: Mi, 15. Jun 2016 10:33

Invoke SOAP-action from HTML/JavaScript

Beitrag 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
ramses
Der Entwickler von "Deep Thought"
Der Entwickler von "Deep Thought"
Beiträge: 2513
Registriert: Mi, 28. Jul 2010 17:16
Hat sich bedankt: 12 Mal
Danksagung erhalten: 77 Mal

Re: Invoke SOAP-action from HTML/JavaScript

Beitrag 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
Valar Morghulis

Gruss Carlo
Stephan Borst
Rookie
Rookie
Beiträge: 12
Registriert: Mi, 15. Jun 2016 10:33

Re: Invoke SOAP-action from HTML/JavaScript

Beitrag 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
ramses
Der Entwickler von "Deep Thought"
Der Entwickler von "Deep Thought"
Beiträge: 2513
Registriert: Mi, 28. Jul 2010 17:16
Hat sich bedankt: 12 Mal
Danksagung erhalten: 77 Mal

Re: Invoke SOAP-action from HTML/JavaScript

Beitrag 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
Valar Morghulis

Gruss Carlo
Stephan Borst
Rookie
Rookie
Beiträge: 12
Registriert: Mi, 15. Jun 2016 10:33

Re: Invoke SOAP-action from HTML/JavaScript

Beitrag 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
Benutzeravatar
AUGE_OHR
Marvin
Marvin
Beiträge: 12903
Registriert: Do, 16. Mär 2006 7:55
Wohnort: Hamburg
Hat sich bedankt: 19 Mal
Danksagung erhalten: 44 Mal

Re: Invoke SOAP-action from HTML/JavaScript

Beitrag 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
gruss by OHR
Jimmy
Antworten