内容摘要:Web Services组件可由多个利益相关者来共同构建和部署。因此,测试这些组件过程中会发现确定代码质量、可用性等都有很大的难度。Web Services的标准是简单的,数据驱动的,并且共享一个公共的基于XML的基础。
互操作性测试
SOAP和Web Services的承诺之一就是互操作性。就是两个应用系统可以自动交互而不需要人为的介入。Web Services未来成功的关键就在于互操作性。
Web Services互操作性测试套件的目标应针对于测试以下方面:
·服务器分析客户端的SOAP包的能力。
·服务器对包中所含的已编码参数进行反串行化的能力。
·客户端对由服务器作为响应发送而来的SOAP包进行分析的能力。
·客户端对从服务器发回的已编码参数进行反串行化的能力。
测试模式
对于一个WLS客户和.NET Web Services:
·用Microsoft Visual Studio在目录/InetPub/wwwroot/DotNetServices/下创建一个.NET Web Services。
·在WLS端,在为DotNetService 提供了WSDL URL后,用WebLlogic clientgen ant task生成一个clientjar。
·从testclient,对JAVA Stub进行一次调用。
WebLogic Server
.NET Server
.NET Web Service
WLS Client
// STOCK TRADE WEB SERVICE
// The Stock Trade web service executes a trade and returns result.
[WebMethod]
public bool execute(string action, string symbol, int quantity)
{
if(action == null) {
Console.WriteLine("action null");
return false;
}
if(symbol == null) {
Console.WriteLine("symbol null");
return false;
}
if(action.Equals("BUY"))
Console.WriteLine("BUYING quantity: "+ quantity + " of symbol:" + symbol);
else if(action.Equals("SELL"))
Console.WriteLine("SELLING quantity: "+ quantity + " of symbol:" + symbol);
else {
Console.WriteLine("INVALID action: "+ action);
return false;
}
return true;
}
责编:豆豆技术应用