我从来没有用 SOAP 和 ColdFusion 做过任何事情,所以我觉得我可能忽略了一些简单的事情。我已经做了很多阅读并在线查看了示例,但没有任何运气。
我在 php 中有以下代码可以正常工作:
<?php
ini_set("soap.wsdl_cache_enabled", "1");
$myDate = '09/05/2013 01:11am';
$client = new SoapClient("https://www.domain.com/remote/service.svc?wsdl");
$client->response_timeout = 60;//seconds
//paramaters to the webservice
$param=array("requestID"=>uniqid(),
"APIUser"=>"apiuser",
"APIKey"=>"apikey",
"pageCode"=>"pagecode",
"strDate"=> $myDate);
$result = $client->AppointmentTimes($param);
?>
在 ColdFusion 中,我尝试使用以下代码复制此功能:
<cfscript>
stCust = StructNew();
stCust.requestID = CreateUUID();
stCust.APIUser = "apiuser";
stCust.APIKey="apikey";
stCust.pageCode="pageCode";
stCust.strFromDate = "09/05/2013 01:11am";
checkTimes = CreateObject("webservice","https://www.domain.com/remote/service.svc?wsdl" );
availTimes = checkTimes.AppointmentTimes(stCust);
</cfscript>
我收到的错误是:
Web service operation AppointmentTimes with parameters {{
STRFROMDATE={09/05/2013 01:11am},
APIUSER={apiuser},
PAGECODE={pagecode},
REQUESTID={0E6D4260-1143-300A-67B00B0F8203F795},
APIKEY={apikey}
}}
cannot be found.
我已经查看了 API 文档以及 Java 存根,但无法弄清楚我在 ColdFusion 端做错了什么。
编辑: 在阅读了 Ben Nadel 博客上的建议后,我也尝试了以下方法:
<cfsavecontent variable="soap">
<cfoutput>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<soap-env:envelope xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
xmlns:tns="http://tempuri.org/"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsp="http://www.w3.org/ns/ws-policy"
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:wsa10="http://www.w3.org/2005/08/addressing"
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap-env:body>
<tns:appointmenttimes xmlns:tns="http://tempuri.org/">
<tns:requestid>
5126adcc913f6
</tns:requestid>
<tns:apiuser>
userid
</tns:apiuser>
<tns:apikey>
apikey
</tns:apikey>
<tns:pagecode>
pagecode
</tns:pagecode>
<tns:strdate>
09/05/2013 01:11am
</tns:strdate>
</tns:appointmenttimes>
</soap-env:body>
</soap-env:envelope>
</cfoutput>
</cfsavecontent>
<cfdump var="#soap#">
<cfhttp url="https://www.domain.com/remote/service.svc" method="post" result="httpResponse">
<cfhttpparam type="header" name="content-type" value="text/xml">
<cfhttpparam type="header" name="SOAPAction" value="">
<cfhttpparam type="header" name="content-length" value="#len(soap)#">
<cfhttpparam type="header" name="charset" value="utf-8">
<cfhttpparam type="xml" name="message" value="#trim(soap)#">
</cfhttp>
<cfdump var="#httpResponse#">
并收到以下信息:
struct
Charset [empty string]
ErrorDetail [empty string]
Filecontent Bad Request
Header HTTP/1.1 400 Bad Request
Content-Type: text/html
Date: Wed, 04 Sep 2013 08:29:03 GMT
Cache-Control: private
X-AspNet-Version: 2.0.50727
Content-Length: 11
Server: Microsoft-IIS/7.5
Mimetype text/html
Responseheader
struct
Cache-Control private
Content-Length 11
Content-Type text/html
Date Wed, 04 Sep 2013 08:29:03 GMT
Explanation Bad Request
Http_Version HTTP/1.1
Server Microsoft-IIS/7.5
Status_Code 400
X-AspNet-Version 2.0.50727
Statuscode 400 Bad Request
Text YES