使用tcpmon做监听:
第一步:打开tcpmon,添加以下参数:
然后addMonitor,然后进入到监听界面
第二步:改CalculatorService的代码:
package org.langsin.ws.client;
import java.net.MalformedURLException;
import java.util.Collection;
import java.util.HashMap;
import javax.xml.namespace.QName;
import org.codehaus.xfire.XFireRuntimeException;
import org.codehaus.xfire.aegis.AegisBindingProvider;
import org.codehaus.xfire.annotations.AnnotationServiceFactory;
import org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.jaxb2.JaxbTypeRegistry;
import org.codehaus.xfire.service.Endpoint;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.soap.AbstractSoapBinding;
import org.codehaus.xfire.transport.TransportManager;
public class CalculatorServiceClient {
private static XFireProxyFactory proxyFactory = new XFireProxyFactory();
private HashMap endpoints = new HashMap();
private Service service0;
public CalculatorServiceClient() {
create0();
Endpoint CalculatorServiceHttpPortEP = service0 .addEndpoint(new QName("http://service.test.com", "CalculatorServiceHttpPort"), new QName("http://service.test.com", "CalculatorServiceHttpBinding"), "http://localhost:5555/myxfire/services/CalculatorService");
endpoints.put(new QName("http://service.test.com", "CalculatorServiceHttpPort"), CalculatorServiceHttpPortEP);
Endpoint CalculatorServicePortTypeLocalEndpointEP = service0 .addEndpoint(new QName("http://service.test.com", "CalculatorServicePortTypeLocalEndpoint"), new QName("http://service.test.com", "CalculatorServicePortTypeLocalBinding"), "xfire.local://CalculatorService");
endpoints.put(new QName("http://service.test.com", "CalculatorServicePortTypeLocalEndpoint"), CalculatorServicePortTypeLocalEndpointEP);
}
public Object getEndpoint(Endpoint endpoint) {
try {
return proxyFactory.create((endpoint).getBinding(), (endpoint).getUrl());
} catch (MalformedURLException e) {
throw new XFireRuntimeException("Invalid URL", e);
}
}
public Object getEndpoint(QName name) {
Endpoint endpoint = ((Endpoint) endpoints.get((name)));
if ((endpoint) == null) {
throw new IllegalStateException("No such endpoint!");
}
return getEndpoint((endpoint));
}
public Collection getEndpoints() {
return endpoints.values();
}
private void create0() {
TransportManager tm = (org.codehaus.xfire.XFireFactory.newInstance().getXFire().getTransportManager());
HashMap props = new HashMap();
props.put("annotations.allow.interface", true);
AnnotationServiceFactory asf = new AnnotationServiceFactory(new Jsr181WebAnnotations(), tm, new AegisBindingProvider(new JaxbTypeRegistry()));
asf.setBindingCreationEnabled(false);
service0 = asf.create((org.langsin.ws.client.CalculatorServicePortType.class), props);
{
AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0, new QName("http://service.test.com", "CalculatorServicePortTypeLocalBinding"), "urn:xfire:transport:local");
}
{
AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0, new QName("http://service.test.com", "CalculatorServiceHttpBinding"), "http://schemas.xmlsoap.org/soap/http");
}
}
public CalculatorServicePortType getCalculatorServiceHttpPort() {
return ((CalculatorServicePortType)(this).getEndpoint(new QName("http://service.test.com", "CalculatorServiceHttpPort")));
}
public CalculatorServicePortType getCalculatorServiceHttpPort(String url) {
CalculatorServicePortType var = getCalculatorServiceHttpPort();
org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
return var;
}
public CalculatorServicePortType getCalculatorServicePortTypeLocalEndpoint() {
return ((CalculatorServicePortType)(this).getEndpoint(new QName("http://service.test.com", "CalculatorServicePortTypeLocalEndpoint")));
}
public CalculatorServicePortType getCalculatorServicePortTypeLocalEndpoint(String url) {
CalculatorServicePortType var = getCalculatorServicePortTypeLocalEndpoint();
org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
return var;
}
}
修改的就是蓝底的那些部分;
然后跑Test.java文件:
就得到侦听结果了
使用jMeter对webService进行监听
打开jMeter,添加线程组:
参数如下:
再添加webservice侦听
参数如下:
添加监听器:
类似的三种结果呈现形式:
然后运行,
然后就可以看到结果了:
用表格查看结果方式:
查看结果树: