急:有点难的问题,如何集成WSE3.0来使用WebTest测试WebService

huazaiboy 2007-05-21 10:04:37
我准备用WebTest来测试我公司开发的WebService,遇到了一个问题,我公司的WebService是集成了WSE3.0的安全机制。使用WebServcie必须有Security token。 公司的项目是通过Proxy来访问WebService的,客户端和服务器端都有相应实现。 而WebTest必须使用WebTestRequest类来访问WebServcie. 我不知道该如何集成WSE3.0的安全机制来顺利地使用WebTest测试我公司的WebService了。以下是我的WebTest代码,因为没通过安全认证而测试失败。 谢谢,急盼回音!

namespace TestProject2
{
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TestTools.WebTesting;


public class WebTest5Coded : WebTest
{

public WebTest5Coded()
{
this.PreAuthenticate = true;
}

public override IEnumerator<WebTestRequest> GetRequestEnumerator()
{
WebTestRequest request1 = new WebTestRequest("http://hst-server/HstAscWebService/ASCWebService.asmx");
request1.Method = "POST";
request1.Headers.Add(new WebTestRequestHeader("SOAPAction", "asc.hstsoftware.net/GetCPTCode"));
request1.Headers.Add(new WebTestRequestHeader("Proxy-Authorization", "btang"));
StringHttpBody request1Body = new StringHttpBody();
request1Body.ContentType = "text/xml";
request1Body.BodyString = @"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
<soap:Body>
<GetCPTCode xmlns=""asc.hstsoftware.net"">
<CPTCode>1</CPTCode>
<centerID>1</centerID>
<requestingUserID>btang</requestingUserID>
</GetCPTCode>
</soap:Body>
</soap:Envelope>";
request1.Body = request1Body;
yield return request1;
}
}
}

...全文
379 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
PODstorm 2007-08-16
  • 打赏
  • 举报
回复
UP...ms 很难的问题
bengougou 2007-08-16
  • 打赏
  • 举报
回复
Bill把分给我吧,我分少的可怜。
bwangel 2007-05-30
  • 打赏
  • 举报
回复
给你顶,代码仔细检查没有? 试试编一个最简单的WEBSERVICE看行不行
klint_khl1 2007-05-30
  • 打赏
  • 举报
回复
给微软的技术人员,看他能提供给你什么资料或说明的
huazaiboy 2007-05-27
  • 打赏
  • 举报
回复
一周了,接着顶起来
huazaiboy 2007-05-22
  • 打赏
  • 举报
回复
第二天了,CSDN的高人们倒是出来啊,迫切等待着解决方案
playzxw 2007-05-21
  • 打赏
  • 举报
回复
帮你顶!
huazaiboy 2007-05-21
  • 打赏
  • 举报
回复
没有人知道吗? 顶起来,CSDN的高人们过来看看啊.

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧