×

[PR]この広告は3ヶ月以上更新がないため表示されています。
ホームページを更新後24時間以内に表示されなくなります。


Googleを追いかけろ!

.

参照ページ(Goolge)


WWW を検索 Googleを追いかけろ! を検索



* Section 1: Creating a Wsdl Object

var wsdl = SoapService.wsdl("http://www.webservicex.net/geoipservice.asmx?wsdl");

* Section 2: Querying a Wsdl Object

 Logger.log(wsdl.getServiceNames());

  <wsdl:service name="GeoIPService">

* Section 3: Getting a WsdlService Object

 var geoService = wsdl.getService("GeoIPService");

 var geoService = wsdl.getGeoIPService();

* Section 4: Querying a WsdlService Object

Logger.log(geoService.getOperationNames());

* Section 5: Creating Web Service Paramaters

  POST /geoipservice.asmx HTTP/1.1
  Host: www.webservicex.net
  Content-Type: text/xml; charset=utf-8
  Content-Length: length
  SOAPAction: "http://www.webservicex.net/GetGeoIP"

  <?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>
      <GetGeoIP xmlns="http://www.webservicex.net">
        <IPAddress>72.14.228.129</IPAddress>
      </GetGeoIP>
    </soap:Body>
  </soap:Envelope>

   <GetGeoIP xmlns="http://www.webservicex.net">
      <IPAddress>72.14.228.129</IPAddress>
    </GetGeoIP>

var param = Xml.element("GetGeoIP", [
                Xml.attribute("xmlns", "http://www.webservicex.net"),
                Xml.element("IPAddress", [
                  "72.14.228.129"
                ])
              ]);

* Section 6: Testing a Soap Operation

  var envelope = geoService.getSoapEnvelope("GetGeoIP", param)
  Logger.log(envelope);

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                     xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
                     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
      <GetGeoIP xmlns="http://www.webservicex.net">
        <IPAddress>72.14.228.129</IPAddress>
      </GetGeoIP>
    </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>

* Section 7: Invoking a Soap Operation

  var result = geoService.invokeOperation("GetGeoIP", [param]);
var result = geoService.GetGeoIP(param);

* Section 8: Working with a Soap Operation Result

Logger.log(result.toXmlString());
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  <GetGeoIPResponse xmlns="http://www.webservicex.net">
    <GetGeoIPResult>
      <ReturnCode>1</ReturnCode>
      <IP>72.14.228.129</IP>
      <ReturnCodeDetails>Record Found</ReturnCodeDetails>
      <CountryName>UNITED STATES</CountryName>
      <CountryCode>US</CountryCode>
    </GetGeoIPResult>
  </GetGeoIPResponse>
Logger.log(result.Envelope.Body.GetGeoIPResponse.GetGeoIPResult.CountryCode.Text);

* Summary and Complete Code

 function determineCountryFromIP(ipAddress) {
    var wsdl = SoapService.wsdl("http://www.webservicex.net/geoipservice.asmx?wsdl");
    var geoService = wsdl.getGeoIPService();

    var param = Xml.element("GetGeoIP", [
                  Xml.attribute("xmlns", "http://www.webservicex.net"),
                  Xml.element("IPAddress", [
                    ipAddress
                  ])
                ]);

    var result = geoService.GetGeoIP(param);
    return result.Envelope.Body.GetGeoIPResponse.GetGeoIPResult.CountryCode.Text;
  }