Web services 如何将webmethod发布到HTTPHandler.ashx文件

Web services 如何将webmethod发布到HTTPHandler.ashx文件,web-services,coldfusion,httphandler,httpcontext,Web Services,Coldfusion,Httphandler,Httpcontext,摘要 如何在Web服务中创建HTTPContext?或者从Web服务发布到Handler.ashx 背景 我有一个Cold Fusion web应用程序,它使用表单身份验证,但通过以下脚本以某种方式实现了Windows身份验证: <cfscript> ws = CreateObject("webservice", "#qTrim.webServiceName#"); ws.setUsername("#qTrim.trimAcct#"); ws.setPassw

摘要

如何在Web服务中创建HTTPContext?或者从Web服务发布到Handler.ashx

背景

我有一个Cold Fusion web应用程序,它使用表单身份验证,但通过以下脚本以某种方式实现了Windows身份验证:

<cfscript>
    ws = CreateObject("webservice", "#qTrim.webServiceName#");
    ws.setUsername("#qTrim.trimAcct#");
    ws.setPassword("#qTrim.trimpwd#");
    wsString=ws.UploadFileCF("#qTrim.webserviceurl#","#objBinaryData#", "#qFiles.Filename#", "Document", "#MetaData#");
</cfscript>

假设您的CF站点运行在IIS上,而不是Apache或其他web服务器上,这可能会起作用:

将调用Web服务的.cfm文件放入站点上自己的子文件夹中。将该文件夹的身份验证属性设置为使用匿名身份验证,但将用户标识设置为成功调用Web服务的Windows域帐户(单击下面显示的对话框上的Set…(设置…)按钮并输入相应的凭据)


尝试了很多次,但无法确定如何正确格式化本文末尾的代码段。@Dan Short-感谢您修复代码格式。诀窍是什么?我单击了插入代码符号并将代码粘贴到蓝色的插入点上,然后检查所有代码行是否缩进了4个或更多的空格。我还删除了一些字符串常量中带有HTML尖括号的行,它认为这只是愚蠢的标记。我在最后一个项目符号和代码开头之间添加了“代码”一词,它开始呈现。不知道为什么:)
namespace WebClient
{
    public class DownloadHandler : IHttpHandler
    {
    ASMXproxy.FileService brokerService;
    public void ProcessRequest(HttpContext context)
    {
         brokerService = new ASMXproxy.FileService();
         string recNumber = context.Request.Form["txtRecordNumber"];
         brokerService.Url = context.Request.Form["txtURL"];
         string trimURL = context.Request.Form["txtFakeURLParm"];  // not a real URL but parms to connect to TRIM
         brokerService.Timeout = 9999999;
         brokerService.Credentials = System.Net.CredentialCache.DefaultCredentials;
         byte[] docContent;
         string fileType;
         string fileName;
         string msgInfo = brokerService.DownloadFile(trimURL, recNumber, out docContent, out fileType, out fileName);
         string ContentType = MIMEType.MimeType(fileType);
         context.Response.AppendHeader("Content-Length", docContent.Length.ToString());
         context.Response.AppendHeader("content-disposition", "attachment; filename=\"" + fileName + "\"");
         context.Response.ContentType = ContentType;
         context.Response.OutputStream.Write(docContent, 0, docContent.Length);
         context.Response.OutputStream.Flush();
     }
     public bool IsReusable
     {
         get
        {
             return false;
        }
     }
     }
}