---from the web, thanks to the provider
The Wsexplorer and TCP/IP monitor tools themselves exist in Eclipse and MyEclipse
Reasons to use the tool:
1, using the tool can better understand the process of WebService request
2. Use tool Wsexplore to get the format of SOAP data sending and receiving
3, using the tool TCP/IP monitor can monitor the interceptor request header and response header specific data
What is SOAP?
Soap is a text protocol based on XML Encoding specification, which simply means that SOAP transmits XML data on the basis of HTTP to implement remote invocation "No matter what language your server is written in, as long as the XML data of the SOAP protocol is received and the XML data of the SOAP protocol is returned, Can be called by any language "
Use Wsexplorer instance: Verify QQ is online
When Qqcheckonline validation is used in Qqonlinewebservicesoap, the returned
Qqcheckonlineresponse
Qqcheckonlineresult (String): N
Click Source to see the details, as follows:
1: This is the message format that is emitted:
<soapenv:envelope xmlns:soapenv= "http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0= "http://WebXml.com.cn/" Xmlns:xsd= "Http://www.w3.org/2001/XMLSchema" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" >
-<soapenv:Body>
-<q0:qqCheckOnline>
<q0:qqCode>870931520</q0:qqCode>
</q0:qqCheckOnline>
</soapenv:Body>
</soapenv:Envelope>
2: The following is the received XML format
<soap:envelope xmlns:soap= "http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd= "http://www.w3.org/2001/ XmlSchema "xmlns:xsi=" Http://www.w3.org/2001/XMLSchema-instance ">
-<soap:Body>
-<qqcheckonlineresponse xmlns= "http://WebXml.com.cn/" >
<qqCheckOnlineResult>N</qqCheckOnlineResult>
</qqCheckOnlineResponse>
</soap:Body>
</soap:Envelope>
When using Qqcheckonline validation in Qqonlinewebservicehttpget or Qqonlinewebservicehttppost, the return is
<?xml version= "1.0" encoding= "Utf-8"?>
<string xmlns= "http://WebXml.com.cn/" >N</string>
Using TCP/IP Monitor
TCP/IP monitor can not only see the SOAP data, but also get the HTTP request and the received header information.
1. Location: This tool is located in: Window>show view>other>myeclipse Common (Common tool) >TCP/IP Monitor
2, this tool, the equivalent of an agent, after starting it will listen to a local port, and then forward the request to the specified destination IP and port.
Once the data has been obtained, the data is returned intact to the customer. In the eyes of the customer, always the first visit should be this agent, otherwise we will not see the process of data transmission.
4. Configuration options:
On the TCP/IP monitor interface that opens: View Menu (the small arrow at the top right) >properties>add (added to the right)
Set to the following properties:
The first step:
1) Local monitoring port (listen on local port number): 9876, arbitrarily set a 4-bit port number, one will be accessed through the form of http://127.0.0.1:9876
2) host name (the server to listen to, such as www.2cto.com): 127.0.0.1– Because this machine has published a WebService, listen to the native IP. It can also be any host.
3) port (the port of the target server to listen on): 6666-because we release the WebService as Http://127.0.0.1:6666/helloworld, 6666 is the port number that needs to be monitored.
4) type (type of listener):
--TCP/IP: will use the original address to continue accessing the next request, such as user input: HTTP://127.0.0.1:9876/HELLOWORLD?WSDL This will return the WSDL service access address to the previous.
--HTTP: The next request will continue to be accessed using the destination address. As user input: HTTP://127.0.0.1:9876/HELLOWORLD?WSDL will use Http://127.0.0.1:6666/helloworld to access the Sayhi method when requesting the method. This method will no longer be proxied. Because it's not the port number you're listening to.
At the listening type, I selected TCP/IP and then viewed in the returned WSDL file by entering: HTTP://127.0.0.1:9876/HELLOWORLD?WSDL in the Address bar: <soap:address location= " http: ... "/> address changes.
Time Out: Sets the connection duration for unsuccessful access, which remains at 0, which is not set.
After setting, click OK button, then click on the right of the Start button, monitoring has been started.
Step Two:
Configure the WSDL URL on myeclipse WebService: http://127.0.0.1:9876/helloworld?wsdl, and note the port that is used for myeclipse TCP/IP monitor. Instead of just visiting our published http://127.0.0.1:6666/helloworld?wsdl
How do I modify the contents of a WSDL file?
Use annotations for WebService.
1. @WebService-Define Service
2. @WebMethod-Definition method
3. @WebResult-Define the return value
4. @WebParam-Define Parameters
Note: For annotations, different versions support varying degrees:
1, 1.5 does not support.
2. The pre-1.6.0_20 version must use full annotations.
3, 1.6.0_21 can only use @webservice to annotate the class.
The role of annotations:
With WebService annotations, you can describe Web services more like that. This generates a WSDL document.
When WebService annotations are modified, the client-generated code is also affected.
The method name and parameter name of the call also changed.
Example:
@WebService (name= "MyName",//corresponds to porttype name= "MyName"
Portname= "MyPort",//Port Name= "MyPort" in the corresponding service
Servicename= "MyService",//corresponding service name= "MyService"
Targetnamespace= "Http://leaf.com/mynamespace")//You can write a package similar to Java
public class helloworld{
private static SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");
@WebMethod (action= "myaction",//define a soapaction= "myaction" to find this method to perform
Operationname= "Myoperationname")//define the method that can be called, generate the specific method of the corresponding class, Operation Name= "..."
Public @WebResult (name= "Mysayhelloresult") string//defines the name of the return value
SayHello () {
return "HelloWorld";
}
@WebMethod (action= "mysayhiaction", Operationname= "Mysayhioperationname")
Public @WebResult (name= "Mysayhiresult") String Sayhi (@WebParam (name= "Myparaname",
Put the parameter in the header information for the protection parameter, default in body
Header=true,
mode=mode.in)
String name) {
String str = "Hello:" +name+ ", the current time is:" +sdf.format (New Date ());
return str;
}
public static void Main (string[] args) {
Endpoint.publish ("Http://127.0.0.1:6666/helloworld", newHelloWorld ());
}
}
3: After the above program is released, we access it through MyEclipse's WebService Explorer.
You will find a message that is not the same as before, but in fact, the same method is still called.
4: Use Wsimport–s again. HTTP://127.0.0.1:6666/HELLOWORLD?WSDL generates Java code and then calls
The following is the calling code (which can be described in beyond recognition, but the same work is done.) )
Package com.leaf.mynamespace;
public class Main {
public static void Main (string[] args) {
By analyzing the WSDL, we know that calling Getmyport from MyService returns myname
MyName MyName = new MyService (). Getmyport ();
Call the Sayhi method through MyName's Mysayhioperationname
String str = myname.mysayhioperationname ("Wang Jian");
System.err.println (str);
}
}
WebService (b)