Reputation: 1037
I have a webservice created in PHP using ZendSOAP, the url is as follows:
mysite.net/webservice/wsdl
. The WSDL definitions are as below:
<?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>
When I try to send data to the web service using ColdFusion I get the following error :
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)
My ColdFusion code is as below :
<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#">
Any help please?
Thanks.
Upvotes: 4
Views: 473
Reputation: 28873
(From comments ...)
An error occurred while Parsing an XML document
Update: Then the response is not what you were expecting (i.e. not valid xml). Dump the response variable to see what it actually contains, <cfdump var="#rawXMLPaymentStatus#">
Nothing to do with the error, but you may want to look into using createObject() to consume web services. It does the same thing as the cfinvoke, but the syntax is a little more compact:
<!--- 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#">
I get the following error: An error occurred while executing the application. Please try again or contact the administrator.
Sounds like you have custom error handling enabled, so the app is displaying a generic message instead of the real error. Assuming this is your DEV environment, temporarily disable it. Otherwise, it will be hard to troubleshoot since you won't be able to see the real error messages. Failing that, wrap the code block in a cftry/cfcatch. Dump the error in the catch clause and edit your question to include the full error message. Trycf.com Example.
Upvotes: 2