【问题标题】:Coldfusion web service error, "Unable to parse WSDL as an XML document."Coldfusion Web 服务错误,“无法将 WSDL 解析为 XML 文档。”
【发布时间】:2011-03-09 04:18:45
【问题描述】:

我正在尝试获取运行 CF9 IIS7 的 Web 服务

testpage.cfm

<cfinvoke webservice ="https://nww.eastwickpark.nhs.uk/cfcs/test.cfc?wsdl"
  method ="echoString"
  input = "hello" 
  returnVariable="foo">

<cfoutput>#foo#</cfoutput>

test.cfc

<cfcomponent output="false" access="public"  returntype="string">
  <cffunction 
      name = "echoString" 
      returnType = "string" 
      output = "no" 
      access = "remote">
    <cfargument name = "input" type = "string">
    <cfreturn #arguments.input#>
  </cffunction>
</cfcomponent>

错误信息是

 Unable to parse WSDL as an XML document.
Parsing error: Fatal Error: URI=null Line=83: The element type "img" must be terminated by the matching end-tag "".
It is recommended that you use a web browser to retrieve and examine the requested WSDL document to ensure it is correct.

The error occurred in C:\inetpub\wwwroot\cf\testpage.cfm: line 4

2 : <cfinvoke webservice ="https://nww.eastwickpark.nhs.uk/cfcs/test.cfc?wsdl"
3 :   method ="echoString"
4 :   input = "hello" 
5 :   returnVariable="foo">
6 : 

我可以在浏览器中转到https://nww.eastwickpark.nhs.uk/cfcs/test.cfc 并获取组件信息页面。

如果我浏览到 http://nww.eaastwickpark.nhs.uk/cfcs/test.cfc?wdsl 我会得到

<wsdl:definitions targetNamespace="http://cfcs" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://cfcs" xmlns:intf="http://cfcs" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://rpc.xml.coldfusion" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by ColdFusion version 9,0,0,251028-->
 <wsdl:types>
  <schema targetNamespace="http://rpc.xml.coldfusion" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
   <complexType name="CFCInvocationException">
    <sequence/>
   </complexType>
  </schema>
 </wsdl:types>

   <wsdl:message name="CFCInvocationException">

      <wsdl:part name="fault" type="tns1:CFCInvocationException"/>

   </wsdl:message>

   <wsdl:message name="echoStringRequest">

      <wsdl:part name="input" type="xsd:string"/>

   </wsdl:message>

   <wsdl:message name="echoStringResponse">

      <wsdl:part name="echoStringReturn" type="xsd:string"/>

   </wsdl:message>

   <wsdl:portType name="Test">

      <wsdl:operation name="echoString" parameterOrder="input">

         <wsdl:input message="impl:echoStringRequest" name="echoStringRequest"/>

         <wsdl:output message="impl:echoStringResponse" name="echoStringResponse"/>

         <wsdl:fault message="impl:CFCInvocationException" name="CFCInvocationException"/>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="test.cfcSoapBinding" type="impl:Test">

      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="echoString">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="echoStringRequest">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://cfcs" use="encoded"/>

         </wsdl:input>

         <wsdl:output name="echoStringResponse">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://cfcs" use="encoded"/>

         </wsdl:output>

         <wsdl:fault name="CFCInvocationException">

            <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="CFCInvocationException" namespace="http://cfcs" use="encoded"/>

         </wsdl:fault>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="TestService">

      <wsdl:port binding="impl:test.cfcSoapBinding" name="test.cfc">

         <wsdlsoap:address location="https://nww.eastwickpark.nhs.uk/cfcs/test.cfc"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>

cfc 的真实路径是 C:\inetpub\wwwroot\cf\cfcs\test.cfc 即不直接在 web 根目录下,所以我有一个映射

逻辑路径 /cfcs
目录路径 C:\inetpub\wwwroot\cf\cfcs

我不明白...

更新了,越来越近了,如果我从 application.cfc 中删除我的 onRequestStart 方法,它可以正常工作。

<cffunction name="onRequestStart" output="false" returnType="void">

    <cfinvoke component="cfcs.security" method="getControlData" returnvariable="controlData">
        <cfinvokeargument name="dsn" value="#application.dsn#">
    </cfinvoke>
    <!--- if site has been closed force a logout and direct to siteclosed notice--->
    <cfif #controlData.siteOpen# is false>
        <CFSET structDelete(session, 'auth')>
        <cflocation url='siteclosed.cfm' addtoken='No'>
        <cfabort>
    </cfif>
    <!--- If user is not logged in, force them to do so now ---> 
    <cfif not isDefined("session.auth.isLoggedIn")> 
        <!--- Check if page is excluded from authentication --->
        <cfinvoke component="cfcs.security" method="checkIfUnathenticatedPage" returnvariable="pageUnauthenticated">
            <cfinvokeargument name="dsn" value="#application.dsn#">
        </cfinvoke>
        <cfif pageUnauthenticated is 1>
            <cfset currentPage="#listlast(CGI.script_name,"/")#">
            <cfinclude template='#currentPage#'>
            <cfabort>
        <cfelse>
            <!--- page is not excluded from authentication --->             
            <!--- If the user is now submitting "loginForm" form, --->
            <!--- Include "Login Check" code to validate user --->
            <cfif isDefined("form.username")> 
                <cfinclude template="loginCheck.cfm">
            </cfif>
            <cfinclude template="loginForm.cfm">
            <cfabort>
        </cfif>
    </cfif> 

</cffunction> 

登录表单中有一张图片,可能是神秘的img标签被吸进去的地方。

【问题讨论】:

  • 通过 https 提供网络服务会不会有问题?
  • 我很困惑 位错误来自哪里,因为 img 没有出现在调用页面、cfc 或 application.cfc 或生成的 wdsl 页面中?
  • 您是否将ssl证书添加到java keystore并重新启动coldfusion?我猜您遇到了证书错误,并且该错误包括 img 标签。
  • 我没有,但正如我在下面所说的,它也仅在 http 下发生。我想我越来越近了,如果我从 application.cfc 中取出我的 onRequestStart 方法,它就可以工作。我已经用我的 onrequestStart 方法更新了最初的帖子,这似乎正在使用网络服务
  • 好的,所以它在我的 onRequestStart 方法中。有没有办法覆盖 application.cfc 的那部分,以便在子目录 application.cfc 中没有 onRequestStart 方法?

标签: web-services coldfusion


【解决方案1】:

该 sub 中的空白 Application.cfc 将适用于纯粹的公共 cfcs。 但是,如果它不是一个广泛开放的 cfc(始终是公开的),我通常会以不同的方式解决这个问题。即使是这样,您仍然可以处理那种 AOP 风格。

如果你想在 onRequestStart 方法中应用一致的面向方面的安全性,我通常会做这样的事情(例如在这里简化):

function onRequestStart(sRequestedObject) {
  if(sRequestedObject does not contain '.cfc') { // Always suppress output in a cfc
    checkRegularLoginSecurity(sRequestedObject); // This can allow to pass, redirect, etc.
  } else {
    return checkCFCSpecificSecurity(sRequestedObject) // returns true or false 
    // false will effectively kill the request, true will go to the next event
  }
}

这样,我可以使用某种安全方法检查 CFC,而不仅仅是重定向到登录页面(也许它会查找 IP 块或 URL 值令牌,或者如果它看到 cfc 在我的 securityObjects 网格,它只是让它继续。否则它可以根据需要适当地采取行动。还有 onCFCRequest() 可以专门针对 cfc 请求处理基本的 AOP 安全性。

【讨论】:

    【解决方案2】:

    您是否尝试过仅使用 HTTP 来实现?我看到您正在使用 HTTP 和 HTTPS 的混合,所以可能在某个地方存在问题。

    您的cfcomponent 标签也不需要accessreturntype 属性——它们仅适用于cffunction 标签。不确定这是否会让你感到困惑。

    编辑:

    问题我认为是你的onRequestStart()实际上包含一个登录页面,如果他们没有登录,对吧?对于您的 Web 服务请求,您不希望这样。

    您可以编写一个子目录 CFC,其中 extends 是更高级别的 CFC,并编写一个不使用 onRequestStart() 的代码。请参阅here 的更多信息。

    【讨论】:

    • 感谢 Ciaran,删除了 cfcomponent 中多余的属性并尝试仅使用 http 和完全相同的错误消息。
    • 是的,如上所述解决了它,我没想到 CFC 输出会被我的 OnRequestStart 干扰,但是 CFC 目录中的“空” application.cfc 可以解决这个问题。跨度>
    【解决方案3】:

    您是否尝试过刷新 WSDL(通过代码或通过管理员)?请记住,CF 缓存 WSDL 返回。如果您之前抛出错误,它可能仍会被缓存。

    【讨论】:

      猜你喜欢
      • 2011-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多