给它做代理之后你这个端口是什么?
做一个代理.
Local monitoring port:本地的监听端口.你要给谁做代理,那么给它做代理之后,你这个代理的端口是什么?
现在要给百度做一个代理.
能看到请求和响应的消息.就是它百度页面给你返回的代码.
这个东西也能应用到我们的WebService上.从WebService上能看到请求和响应的消息体具体的详细的东西.
http://localhost:8077/person?wsdl
这个文档我们就可以把它生成一个客户端代码.我们调用它的时候每一次调用都会发生请求消息和响应消息在一个监听器里面给我们展示出来.继续来把这个代码做一个生成.
添加Person的时候它就应该发送一个消息体了.那这个消息体应该就是
修改监听器:
第一步首先它的目的是用GET的方式读WSDL文档,读这个说明书.读完说明书当你走到下面这个添加的时候,它就会根据说明书来发送一个消息体.
再往下走,添加Person的时候就应该发送一个消息体了.这个消息体就应该是Envelope开头,然后以Body以及Person的成员变量作为属性来发送过去.那么这边
Content-Type:text/xml;charset=utf-8.它请求到的Host地址就是你本机的代理:localhost:8077.你添加完之后它要给你一个添加成功的响应消息.
POST /person HTTP/1.1 Accept: text/xml, multipart/related Content-Type: text/xml; charset=utf-8 SOAPAction: "http://server.rl.com/PersonServer/addPersonRequest" User-Agent: JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e Host: localhost:8077 Connection: keep-alive Content-Length: 267 <?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:addPerson xmlns:ns2="http://server.rl.com/"><arg0><address>xiangyashan</address><age>20</age><id>1</id><name>zhaoliu</name></arg0></ns2:addPerson></S:Body></S:Envelope>POST /person HTTP/1.1 Accept: text/xml, multipart/related Content-Type: text/xml; charset=utf-8 SOAPAction: "http://server.rl.com/PersonServer/addPersonRequest" User-Agent: JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e Host: localhost:8077 Connection: keep-alive Content-Length: 266 <?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:addPerson xmlns:ns2="http://server.rl.com/"><arg0><address>gaolaozhang</address><age>25</age><id>2</id><name>tianqi</name></arg0></ns2:addPerson></S:Body></S:Envelope>
HTTP/1.1 200 OK Transfer-encoding: chunked Content-type: text/xml; charset=utf-8 Date: Tue, 24 Oct 2017 04:00:20 GMT 5e <?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body> 50 <ns2:addPersonResponse xmlns:ns2="http://server.rl.com/"/></S:Body></S:Envelope> 0
HTTP/1.1 200 OK Transfer-encoding: chunked Content-type: text/xml; charset=utf-8 Date: Tue, 24 Oct 2017 06:32:07 GMT 5e <?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body> 50 <ns2:addPersonResponse xmlns:ns2="http://server.rl.com/"/></S:Body></S:Envelope> 0
由于返回值是void.void它就不具有这个消息具体的逻辑的内容.
POST /person HTTP/1.1 Accept: text/xml, multipart/related Content-Type: text/xml; charset=utf-8 SOAPAction: "http://server.rl.com/PersonServer/getPersonAllRequest" User-Agent: JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e Host: localhost:8077 Connection: keep-alive Content-Length: 187 <?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getPersonAll xmlns:ns2="http://server.rl.com/"></ns2:getPersonAll></S:Body></S:Envelope>
HTTP/1.1 200 OK Transfer-encoding: chunked Content-type: text/xml; charset=utf-8 Date: Tue, 24 Oct 2017 06:27:01 GMT 5e <?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body> 22f <ns2:getPersonAllResponse xmlns:ns2="http://server.rl.com/"><return><address>xiangyashan</address><age>20</age><id>1</id><name>zhaoliu</name></return><return><address>xiangyashan</address><age>20</age><id>1</id><name>zhaoliu</name></return><return><address>xiangyashan</address><age>20</age><id>1</id><name>zhaoliu</name></return><return><address>xiangyashan</address><age>20</age><id>1</id><name>zhaoliu</name></return><return><address>xiangyashan</address><age>20</age><id>1</id><name>zhaoliu</name></return></ns2:getPersonAllResponse></S:Body></S:Envelope> 0
package com.rl.client; import java.util.List; import com.rl.monitor.Person; import com.rl.monitor.PersonServer; import com.rl.monitor.PersonServerService; public class TestPersonMonitorClient { public static void main(String[] args) { //创建服务访问点集合 PersonServerService pss = new PersonServerService(); //根据服务访问点获得绑定的类 PersonServer server = pss.getPersonServerPort(); //调用具体业务逻辑 Person person = new Person(); person.setId(1); person.setName("zhaoliu"); person.setAge(20); person.setAddress("xiangyashan"); Person person1 = new Person(); person1.setId(2); person1.setName("tianqi"); person1.setAge(25); person1.setAddress("gaolaozhang"); //调用添加人的webservice服务方法 server.addPerson(person); server.addPerson(person1); //调用查询所有人的webservice服务方法 /* List<Person> pList = server.getPersonAll(); for (Person p : pList) { System.out.println("id: "+p.getId()+" name:"+p.getName() + " age:"+p.getAge() ); }*/ } }