Coldfusion使用PHP中的SOAP web服务



我有一个使用ZendSOAP在PHP中创建的Web服务,url如下:CCD_ 1。WSDL定义如下:

<?xml version="1.0"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="mysite.net/webservice" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Soap" targetNamespace="mysite.net/webservice">
<types>
<xsd:schema targetNamespace="mysite.net/webservice" />
</types>
<portType name="SoapPort">
<operation name="cancelTrans">
<documentation>Return cancel payment status</documentation>
<input message="tns:cancelTransIn" />
<output message="tns:cancelTransOut" />
</operation>
</portType>
<binding name="SoapBinding" type="tns:SoapPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="cancelTrans">
<soap:operation soapAction="mysite.net/webservice#cancelTrans" />
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="mysite.net/webservice" />
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="mysite.net/webservice" />
</output>
</operation>
</binding>
<service name="SoapService">
<port name="SoapPort" binding="tns:SoapBinding">
<soap:address location="mysite.net/webservice" />
</port>
</service>
<message name="cancelTransIn">
<part name="transId" type="xsd:string" />
<part name="transDate" type="xsd:string" />
<part name="transAmount" type="xsd:string" />
<part name="token" type="xsd:string" />
</message>
<message name="cancelTransOut">
<part name="return" type="xsd:string" />
</message>
</definitions>

当我尝试使用ColdFusion将数据发送到web服务时,我会收到以下错误:

Detail  Content is not allowed in prolog.
ErrNumber   0
ExceptionMessage    Content is not allowed in prolog.
Message     An error occurred while Parsing an XML document.
StackTrace  coldfusion.xml.XmlProcessException: An error occurred while Parsing an XML document. at coldfusion.xml.XmlProcessor.parse(XmlProcessor.java:287) at coldfusion.xml.XmlProcessor.parse(XmlProcessor.java:246) at coldfusion.runtime.CFPage.XmlParse(CFPage.java:265) at cfmain14870010962322d43b3f2622df2c72d561b2ddfec2d384dfba357452ecfm162910047.runPage(31EC38C4-A2D6-2A5C-5079916F7DB375F4:16) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:251) at coldfusion.tagext.lang.IncludeTag.handlePageInvoke(IncludeTag.java:737) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:573) at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:3698) at cfcfmler2ecfc1489966816$func$RUNIT.runFunction(/home/webs/sbx/www/cfmler.cfc:159) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:492) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:388) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:339) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:234) at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:3544) at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:3524) at cfcfmler2ecfc1489966816$funcPLAYCFMFILE.runFunction(/home/webs/sbx/www/cfmler.cfc:79) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:492) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:425) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:388) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:339) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:234) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:650) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:439) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:409) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:3091) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:3068) at cfgetremote2ecfm1955103781.runPage(/home/webs/sbx/www/getremote.cfm:78) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:251) at coldfusion.tagext.lang.IncludeTag.handlePageInvoke(IncludeTag.java:737) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:573) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.IpFilter.invoke(IpFilter.java:45) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:484) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:43) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:153) at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:30) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:60) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:151) at coldfusion.CfmServlet.service(CfmServlet.java:219) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:536) at org.apache.coyote.ajp.AbstractAjpProcessor.process(AbstractAjpProcessor.java:898) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) 

我的ColdFusion代码如下:

<cfinvoke
method="cancelTrans"
returnvariable="rawXMLPaymentStatus"
webservice="mysite.net/webservice/wsdl">
<cfinvokeargument name="token" value="ABCDEFG">
<cfinvokeargument name="transAmount" value="30.15">
<cfinvokeargument name="transDate" value="20170208">
<cfinvokeargument name="transId" value="123456">
</cfinvoke>
<cfset status = XmlParse(rawXMLPaymentStatus)>
<cfdump var="#status#">

请帮忙吗?

谢谢。

(来自注释…)

分析XML文档时出错

更新:然后响应不是您所期望的(即无效的xml)。转储响应变量以查看它实际包含的内容,<cfdump var="#rawXMLPaymentStatus#">

与该错误无关,但您可能需要研究使用createObject()来使用web服务。它做的事情与cfinvoke相同,但语法更紧凑:

<!--- create the web service instance --->
<cfset ws = createObject("webservice", "http://example.com/webservice/wsdl")>
<!--- invoke the cancelTrans method with appropriate arguments --->
<cfset result = ws.cancelTrans("ABCDEFG", "30.15", "20170208", "123456")>
<!--- display results ---> 
<cfdump var="#result#">

我得到以下错误:执行应用请重试或与管理员联系。

听起来你已经启用了自定义错误处理,所以应用程序显示的是一条通用消息,而不是真正的错误。假设这是您的DEV环境,请暂时禁用它。否则,将很难进行故障排除,因为您将无法看到真正的错误消息。如果未执行此操作,请将代码块包装在一个cf"try/cf捕获"中。转储catch子句中的错误,并编辑您的问题以包含完整的错误消息。Trycf.com示例。

相关内容

  • 没有找到相关文章

最新更新