webservice的soap

1.soap的定义:

 2.使用TCP/IP Monitor监视Soap协议

 eclipse工具,show view-->other-->debug-->TCP/IP Monitor

 

 

 

 

 

 

 2.4

 

 

 

2.5 客户端代码:

package com.client;

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import com.test.WeatherInterfaceImpl;

public class Client2 {
public static void main(String[] args) throws Exception {
//服务的地址
URL url=new URL("http://127.0.0.1:54321/weather?wsdl");
//定义qname,第一个参数是命名空间,第二个参数是wsdl里边的服务名
QName qName=new QName("http://server.com/","WeatherInterfaceImplService");
//创建服务视图
Service service=Service.create(url,qName);
//得到服务端点
WeatherInterfaceImpl weatherInterfaceImpl=service.getPort(WeatherInterfaceImpl.class);

//通过服务端点调用服务方法
String result=weatherInterfaceImpl.queryWeather("郑州");
System.out.println(result);

}
}

2.6运行看TCP/IP Monitor的监测窗口内容

 请求:

 响应:

 3.报错信息

http://127.0.0.1:54321/weather?wsdl无法访问,原因是monitor没有启动

原文地址:https://www.cnblogs.com/curedfisher/p/11850606.html