Web Service Call Need 5 minutes Everytime

Original address: http://my.oschina.net/markho/blog/498283
I encountered a problem when debugging the WebService service today. The server side of the WebService is built with Jaxws (which comes with JDK), and the client used for testing is using Eclipse automatically generates it.

Each time the client calls, the server can accept the request and process the request, but when it returns, the client cannot get a response immediately, and it takes about 5 minutes/300000g milliseconds to get the result.

The code is similar:

the server code com.je.ws.HelloService.java:

package com.je.ws;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;

@WebService(name="helloService" ,portName="helloServicePort" ,targetNamespace="http://www.javaedu.com")
public class HelloService {
 @WebMethod
 public String hello(String name){
 System.out.println("Sev.Hello:" + name);
 return "OK, " + name.length;
 }
 
 public static void main(String[] args){
 Endpoint.publish("http://192.168.3.120:8080/HelloServicePort", new HelloService());
 }
}

Client code, save the code automatically generated by Eclipse, the client call code: com.je.test.JestClient.java:
package com.je.test;
import java.rmi.RemoteException;

public class JestClient {
 public static void main(String[] args) throws RemoteException {
  HelloServiceProxy jp = new HelloServiceProxy();
  String hello = jp.hello("xidada");
  System.out.println(hello);
 }
}

Ask colleagues no one has seen them, and Google/Baidu has few answers. In the end, I kept changing the conditions and finally found the answer. The reason turned out to be the version of the Http protocol... In the method generated by eclipse, add the XXXPortBindingStub.java call method
_call.setProperty(MessageContext.HTTP_TRANSPORT_VERSION,HTTPConstants.HEADER_PROTOCOL_V11);

After adding, OK. The deeper reason is unknown, waiting for experts to answer questions, I hope to help everyone.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326488117&siteId=291194637