Web services Coldfusion web服务错误;无法将WSDL解析为XML文档。”;

Web services Coldfusion web服务错误;无法将WSDL解析为XML文档。”;,web-services,coldfusion,Web Services,Coldfusion,我正在尝试运行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> #福# 试验装置 <cfcomponent

我正在尝试运行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>

#福#
试验装置

<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 : 
无法将WSDL解析为XML文档。
分析错误:致命错误:URI=null Line=83:元素类型“img”必须由匹配的结束标记“”终止。
建议您使用web浏览器检索和检查请求的WSDL文档,以确保其正确性。
错误发生在C:\inetpub\wwwroot\cf\testpage.cfm:第4行
2 : 
6 : 
我可以在浏览器中转到并获得组件信息页面OK

如果我浏览到


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标签被吸进的地方

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

您是否尝试仅使用HTTP来执行此操作?我看到您使用的是HTTP和HTTPS的混合,所以可能在某个地方存在问题

另外,您的
cfcomponent
标记不需要
access
returntype
属性-它们只用于
cffunction
标记。不确定这是否会把你搞砸

编辑:

我认为问题在于,如果您的
onRequestStart()
未登录,那么实际上会包含一个登录页面,对吗?您不希望在web服务请求中使用它


您可以编写一个子目录CFC,它扩展了更高级别的CFC,并编写了不使用的子目录CFC。请参阅更多信息。

该子部分中的空白Application.cfc将适用于纯公共cfc。 但如果它不是一个完全开放的cfc(一直是公共的),我通常会以不同的方式处理它。即使是这样,您仍然可以处理AOP样式

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


通过这种方式,我可以让某种安全方法检查cfc,而不仅仅是重定向到登录页面(可能它查找IP块或URL值令牌,或者如果它在我的securityObjects网格中看到cfc是“public”,它只允许它继续。否则它可以根据需要正确地采取措施。还有onCFCRequest()它可以专门处理cfc请求的基本AOP安全性。

通过https交付web服务会有问题吗?我不知道错误从何而来,因为img没有出现在调用页面、cfc或application.cfc或生成的wdsl页面中?您是否已将ssl证书添加到java密钥库并重新启动rted coldfusion?我猜你得到了一个证书错误,错误包括img标记。我没有,但正如我在下面所说的,它也只发生在http下。我想如果我从application.cfc中取出我的onRequestStart方法,它会工作。我已经用我的onRequestStart方法更新了最初的帖子,这似乎是突破性的g使用web服务OK,这是我的onRequestStart方法中的一部分。是否有办法覆盖application.cfc的这一部分,以便在子目录application.cfc中没有onRequestStart方法?谢谢Ciaran,编辑了cfcomponent中多余的属性,并尝试仅使用http和完全相同的错误消息。是的,作为一个示例除此之外,我不希望CFC输出受到OnRequestStart的干扰,但CFC目录中的“空”application.CFC会解决这个问题。
<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> 
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
  }
}