Using SOAP with default proxy

3140
12
Jump to solution
02-21-2018 01:34 PM
FrancisGagne1
New Contributor II

I'm trying to POST a SOAP request on a service not under my control.

Since it's cross domain, I need to use a proxy.

I am only using Postman for now.

When I call the service directly, the response is good. But when I add https://myserver:3344/proxy.js? before my service url in postman. The service return me "Server was unable to process request. ---> Root element is missing." meaning that my xml I sent is not good anymore.

Can I have some help with SOAP request using the default proxy coming with WebApp Builder?

Is it supported?

Thanks.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
FrancisGagne1
New Contributor II

Instead of using the proxy in WAB to handle the cross domain problem, I passed in a service that handle CORS and all is fine now: https://cors-anywhere.herokuapp.com/ 

I'll setup a cors-anywhere on my client's server but at least I know that works with this one.

View solution in original post

0 Kudos
12 Replies
RobertScheitlin__GISP
MVP Emeritus

Francis,

   I have never seen anyone (including myself) able to get a SOAP request through the JS API.

0 Kudos
FrancisGagne1
New Contributor II

You mean in WAB? 

Because I have another application that uses the 3.16 JS API and it works just fine.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Francis,

  Well if you were able to do it using the JS API then you should be able to do it using WAB. Can you share your code for how you did a SOAP call successfully?

0 Kudos
FrancisGagne1
New Contributor II

Pretty straightforward I guess:

var xhr = new XMLHttpRequest();
xhr.open('POST',esri.config.defaults.io.proxyUrl + '?' + this.somumWebURL,true);

var soapRequest = (
     '<?xml version="1.0" encoding="utf-8"?>' +
     '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
     ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
     ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
     '<soap:Body>' +
     .....................
     '</soap:Body>' +
     '</soap:Envelope>'
);

xhr.onreadystatechange = dojo.hitch(this,function() {
     if (xhr.readyState == 4 && xhr.status == 200) {
           this.loadSOAPResponse(xhr.responseXML);
      } else {
           this.setErrorMessage(xhr.status);
      }
});

xhr.setRequestHeader('Content-Type', 'text/xml; charset=utf8');
xhr.send(soapRequest);

The problem really is the proxy.js included with WAB.

I'm currently trying to find how it process my xml. I'll return with my findings.

RobertScheitlin__GISP
MVP Emeritus

Francis,

OK, I thought you meant you were using esriRequest on a SOAP web service.

0 Kudos
CCWeedcontrol
Occasional Contributor III

Francis are you trying to access a CAMA system?

0 Kudos
FrancisGagne1
New Contributor II

It's a system that automates sms and calls in a city.

0 Kudos
CCWeedcontrol
Occasional Contributor III

I see, I trying to look into accessing out CAMA system from a WAB application and i am not sure how to do i thought maybe you were trying to do that. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

CC,

   I access CAMA Data but I developed a RESTfull web service to do that, since SOAP is difficult to consume in JS.

0 Kudos