Expand my Community achievements bar.

SOLVED

How to make web service in xdp file working in HTML form after conversion

Avatar

Level 2

Hello there,

How to make web service in xdp file work after the xdp file is converted to HTML form? 

For example, the xdp contains javascripts (or use ConnectionSet) to call web service

form1.#subform[0].Button1::click - (JavaScript, server)

      var countryTextField = "AFK";

      var cURL = "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL";
      SOAP.wireDump = false;
      var service = SOAP.connect(cURL);
      var Input = {sCountryISOCode:countryTextField};
      var result = service.FullCountryInfo(Input);
      tfCurrency.rawValue = result.sCurrencyISOCode;
      tfCapital.rawValue = result.sCapitalCity;

 

Is there any way make the web service working in previewHTML or HTML form converted from xdp?

Please suggest.

Thanks in advance.

Harry

 

 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

@harry2ca 

xfa.connectionSet won't work in this case, if rendered at client but you can make a web service call if the script is rendered at server. Yes, if the requirement is to run the script at the client, then you can make an Ajax call to the webservice as below:

 

     if (typeof(xfa.connectionSet)=="undefined") {
              var data = new FormData();
              var xhttp = new XMLHttpRequest();
              xhttp.onreadystatechange=function() {
    //Custom logic//
                 }
              };
               xhttp.open("POST", http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL, true);
               xhttp.send(data);
         }
         else {
             xfa.connectionSet.LookupUser.execute(0);
         }

 

Hope that helps!

View solution in original post

3 Replies

Avatar

Correct answer by
Employee Advisor

@harry2ca 

xfa.connectionSet won't work in this case, if rendered at client but you can make a web service call if the script is rendered at server. Yes, if the requirement is to run the script at the client, then you can make an Ajax call to the webservice as below:

 

     if (typeof(xfa.connectionSet)=="undefined") {
              var data = new FormData();
              var xhttp = new XMLHttpRequest();
              xhttp.onreadystatechange=function() {
    //Custom logic//
                 }
              };
               xhttp.open("POST", http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL, true);
               xhttp.send(data);
         }
         else {
             xfa.connectionSet.LookupUser.execute(0);
         }

 

Hope that helps!

Avatar

Level 2
I couldn't make POST work. I hope to call the FullCountryInfo to get the CountryName from CountryISOCode "AFK". How to pass parameter to a method? Could you provide more details of the code?