Chinaunix首页 | 论坛 | 博客
  • 博客访问: 605599
  • 博文数量: 796
  • 博客积分: 5000
  • 博客等级: 大校
  • 技术积分: 5095
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-10 09:43
文章分类

全部博文(796)

文章存档

2011年(1)

2008年(795)

我的朋友

分类:

2008-09-10 10:07:30

    测试Web Services的有效性、性能、可伸缩性、可靠性以及性时所面临的主要挑战是 Web Services的分布性。

  为了使完整的Web Services能够实现预期的功能,就要求客户端和服务都要满足一系列的要求。接口必须在其WSDL文档中正确描述出来,消息必须遵守传输规范(如HTTP1.1)和消息(如SOAP 1.1)。同时消息必须遵守描述该服务的WSDL文档中的契约,要求同时考虑到消息的内容和传输层的绑定。加上综合的条款、互操作性问题、UDDI注册要求以及一定负载下的性能需求,就很容易发现为什么网络测试不是无足轻重的事情。

  Web Services组件可由多个利益相关者来共同构建和部署。因此,测试这些组件过程中会发现确定代码质量、可用性等都有很大的难度。Web Services的标准是简单的,数据驱动的,并且共享一个公共的基于XML的基础。传统的测试工具可能不足以有效地测试这些标准。而且GUI自动化工具也不足以有效地测试Web Services的接口点和消息格式。

  功能测试

  该测试的目标相当直观易懂:确保能够对给定的请求发送正确的响应。然而,由于Web Services的复杂性,该任务原非想象的那么简单。对于大多数的Web Services而言,它不可能精确预见客户端会发来什么类型的请求。枚举所有可能的请求并不切实可行,因为可能输入的空间要么是没有边界,要么就是无穷大。因此,验证是否能处理大范围的请求类型和参数是极其重要的。

    public boolean execute(String action, String symbol, int quantity)

    throws javax.xml.soap.SOAPException{

       Detail detail = null;

       detail = SOAPFactory.newInstance().createDetail();

       detail.addChildElement( "Stock Trade" ).addTextNode( "failed" );

        System.out.println("execute() in webservices.stock.trade webservice has been invoked

        with following arguments:: action:" + action +

        " symbol:" + symbol + " quantity:" + quantity);

        if(action == null) {

          throw new SOAPFaultException(new QName( "", "ServerFailed" ),

                "action parameter is null.",

                null,

                detail);

        }

        if(symbol == null) {

          throw new SOAPFaultException(new QName( "", "ServerFailed" ),

                "symbol parameter is null.",

                null,

                detail);

     }
      if(action.equalsIgnoreCase("BUY"))

          System.out.println("BUYING quantity: "+ quantity + " of symbol:" + symbol);

          // Invoke method to execute trade here.

        else if(action.equalsIgnoreCase("SELL"))

          System.out.println("SELLING quantity: "+ quantity + " of symbol:" + symbol);

          // Invoke method to execute trade here.

        else

        {

          System.out.println("INVALID action: "+ action);

          throw new SOAPFaultException(new QName( "", "ServerFailed" ),

                "Invalid Action:" + action,

                null,

                detail);

        }

        return true;

      }

[1]   

【责编:John】

--------------------next---------------------

阅读(268) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~