0

我正在尝试使用 Google Apps Scripts 来调用 SOAP 服务调用,并且我一直在尝试修改多种方法来获得响应;但是,我不断收到错误消息。我默认尝试发送存储在我的电子表格中的消息的精确副本,我知道该消息可以通过另一项服务工作......仍然没有运气。这是 Apps 脚本代码:

function getVesselSummaryXMLStringFromName() {
  var wsdl = SoapService.wsdl("http://cgmix.uscg.mil/xml/PSIXData.asmx?WSDL");
  Logger.log(wsdl.getServiceNames());

  var uscgService = wsdl.getPSIXData();

  var sheet = SpreadsheetApp.getActiveSheet();

  //Get working SOAP message
  var envelope = sheet.getRange("D1:D1").getValues();

  Logger.log(envelope);

    var result = uscgService.getenvelope;
    Logger.log(result);
  }

我通过http://www.soapclient.com/soapclient发送的 SOAP 消息是:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://cgmix.uscg.mil" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ><SOAP-ENV:Body><tns:getVesselSummaryXMLString xmlns:tns="http://cgmix.uscg.mil"><tns:VesselID></tns:VesselID><tns:VesselID></tns:VesselID><tns:VesselName>Atlantic Salvor</tns:VesselName><tns:VesselName></tns:VesselName><tns:CallSign></tns:CallSign><tns:CallSign></tns:CallSign><tns:VIN></tns:VIN><tns:VIN></tns:VIN><tns:HullNum></tns:HullNum><tns:HullNum></tns:HullNum><tns:Flag></tns:Flag><tns:Flag></tns:Flag><tns:Service></tns:Service><tns:Service></tns:Service><tns:BuildYear></tns:BuildYear><tns:BuildYear></tns:BuildYear></tns:getVesselSummaryXMLString></SOAP-ENV:Body></SOAP-ENV:Envelope>
4

1 回答 1

1

下面的代码返回一个答案,所以也许你可以帮忙。

...
var url = 'http://cgmix.uscg.mil/xml/PSIXData.asmx?WSDL';
var wsdl = SoapService.wsdl(url);
var servicePSIXData = wsdl.getPSIXData();
var params = Xml.element('getVesselSummaryXMLString', [
    Xml.attribute('xmlns', 'http://cgmix.uscg.mil'),
    Xml.element('VesselID', ['']),
    Xml.element('VesselName', ['Atlantic Salvor']),
    Xml.element('CallSign', ['']),
    Xml.element('VIN', ['']),
    Xml.element('HullNum', ['']),
    Xml.element('Flag', ['']),
    Xml.element('Service', ['']),
    Xml.element('BuildYear', [''])
]);
var result = servicePSIXData.getVesselSummaryXMLString(params);
Logger.log(result.toXmlString());
...

更新

Xml 服务Soap 服务都被视为已弃用

于 2013-08-12T16:35:20.287 回答