Java soapweb服务响应非常慢

Java soapweb服务响应非常慢,java,web-services,soap,wsdl,Java,Web Services,Soap,Wsdl,我生成了一个soapweb服务 当我尝试使用这项服务时,我遇到了一个问题 需要很多时间才能获得超过4分钟的响应 我尝试使用以下测试代码: import javax.jws.WebMethod; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.jws.soap.SOAPBinding.Style; @WebService @SOAPBinding(style = Style.RPC) pub

我生成了一个soapweb服务

当我尝试使用这项服务时,我遇到了一个问题

需要很多时间才能获得超过4分钟的响应

我尝试使用以下测试代码:

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

@WebService
@SOAPBinding(style = Style.RPC)
public interface Balance {


    @WebMethod String getValue();

}
BalanceImpServiceLocator loc = new BalanceImpServiceLocator();
BalanceImpPortBindingStub bindingStub = new BalanceImpPortBindingStub(new URL(loc.getBalanceImpPortAddress()),loc);

System.out.println(" -- start test ----");

String string = bindingStub.getValue()
这是java类

import javax.jws.WebService;



@WebService(endpointInterface = "com.dq.test.web.manager.impl.Balance")
public class BalanceImp implements Balance{


    @Override
    public String getValue() {
        // TODO Auto-generated method stub
        return "test";
    }


}
要发布此web服务,我使用以下代码:

Endpoint.publish,新的BalanceImp

这是wsdl的代码:

<!--
 Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. 
-->
<!--
 Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. 
-->
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://impl.manager.web.test.dq.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://impl.manager.web.test.dq.com/" name="BalanceImpService">
<types/>
<message name="getValue"/>
<message name="getValueResponse">
<part name="return" type="xsd:string"/>
</message>
<portType name="Balance">
<operation name="getValue">
<input message="tns:getValue"/>
<output message="tns:getValueResponse"/>
</operation>
</portType>
<binding name="BalanceImpPortBinding" type="tns:Balance">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="getValue">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://impl.manager.web.test.dq.com/"/>
</input>
<output>
<soap:body use="literal" namespace="http://impl.manager.web.test.dq.com/"/>
</output>
</operation>
</binding>
<service name="BalanceImpService">
<port name="BalanceImpPort" binding="tns:BalanceImpPortBinding">
<soap:address location="http://192.168.1.13:8080/WS/TestSoap"/>
</port>
</service>
</definitions>
我尝试使用另一个发布在网络中的wsdl示例

我还使用eclipse生成客户机

对于这个例子,响应非常快

以下是此示例的源代码:

wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.webservicex.net" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.webservicex.net">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
Get one week weather forecast for valid zip code or Place name in USA
</wsdl:documentation>
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.webservicex.net">
<s:element name="GetWeatherByZipCode">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ZipCode" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetWeatherByZipCodeResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="GetWeatherByZipCodeResult" type="tns:WeatherForecasts"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="WeatherForecasts">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="Latitude" type="s:float"/>
<s:element minOccurs="1" maxOccurs="1" name="Longitude" type="s:float"/>
<s:element minOccurs="1" maxOccurs="1" name="AllocationFactor" type="s:float"/>
<s:element minOccurs="0" maxOccurs="1" name="FipsCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="PlaceName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="StateCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Status" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Details" type="tns:ArrayOfWeatherData"/>
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfWeatherData">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="WeatherData" type="tns:WeatherData"/>
</s:sequence>
</s:complexType>
<s:complexType name="WeatherData">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Day" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="WeatherImage" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="MaxTemperatureF" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="MinTemperatureF" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="MaxTemperatureC" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="MinTemperatureC" type="s:string"/>
</s:sequence>
</s:complexType>
<s:element name="GetWeatherByPlaceName">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="PlaceName" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetWeatherByPlaceNameResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="GetWeatherByPlaceNameResult" type="tns:WeatherForecasts"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="WeatherForecasts" type="tns:WeatherForecasts"/>
</s:schema>
</wsdl:types>
<wsdl:message name="GetWeatherByZipCodeSoapIn">
<wsdl:part name="parameters" element="tns:GetWeatherByZipCode"/>
</wsdl:message>
<wsdl:message name="GetWeatherByZipCodeSoapOut">
<wsdl:part name="parameters" element="tns:GetWeatherByZipCodeResponse"/>
</wsdl:message>
<wsdl:message name="GetWeatherByPlaceNameSoapIn">
<wsdl:part name="parameters" element="tns:GetWeatherByPlaceName"/>
</wsdl:message>
<wsdl:message name="GetWeatherByPlaceNameSoapOut">
<wsdl:part name="parameters" element="tns:GetWeatherByPlaceNameResponse"/>
</wsdl:message>
<wsdl:message name="GetWeatherByZipCodeHttpGetIn">
<wsdl:part name="ZipCode" type="s:string"/>
</wsdl:message>
<wsdl:message name="GetWeatherByZipCodeHttpGetOut">
<wsdl:part name="Body" element="tns:WeatherForecasts"/>
</wsdl:message>
<wsdl:message name="GetWeatherByPlaceNameHttpGetIn">
<wsdl:part name="PlaceName" type="s:string"/>
</wsdl:message>
<wsdl:message name="GetWeatherByPlaceNameHttpGetOut">
<wsdl:part name="Body" element="tns:WeatherForecasts"/>
</wsdl:message>
<wsdl:message name="GetWeatherByZipCodeHttpPostIn">
<wsdl:part name="ZipCode" type="s:string"/>
</wsdl:message>
<wsdl:message name="GetWeatherByZipCodeHttpPostOut">
<wsdl:part name="Body" element="tns:WeatherForecasts"/>
</wsdl:message>
<wsdl:message name="GetWeatherByPlaceNameHttpPostIn">
<wsdl:part name="PlaceName" type="s:string"/>
</wsdl:message>
<wsdl:message name="GetWeatherByPlaceNameHttpPostOut">
<wsdl:part name="Body" element="tns:WeatherForecasts"/>
</wsdl:message>
<wsdl:portType name="WeatherForecastSoap">
<wsdl:operation name="GetWeatherByZipCode">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
Get one week weather forecast for a valid Zip Code(USA)
</wsdl:documentation>
<wsdl:input message="tns:GetWeatherByZipCodeSoapIn"/>
<wsdl:output message="tns:GetWeatherByZipCodeSoapOut"/>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
Get one week weather forecast for a place name(USA)
</wsdl:documentation>
<wsdl:input message="tns:GetWeatherByPlaceNameSoapIn"/>
<wsdl:output message="tns:GetWeatherByPlaceNameSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="WeatherForecastHttpGet">
<wsdl:operation name="GetWeatherByZipCode">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
Get one week weather forecast for a valid Zip Code(USA)
</wsdl:documentation>
<wsdl:input message="tns:GetWeatherByZipCodeHttpGetIn"/>
<wsdl:output message="tns:GetWeatherByZipCodeHttpGetOut"/>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
Get one week weather forecast for a place name(USA)
</wsdl:documentation>
<wsdl:input message="tns:GetWeatherByPlaceNameHttpGetIn"/>
<wsdl:output message="tns:GetWeatherByPlaceNameHttpGetOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="WeatherForecastHttpPost">
<wsdl:operation name="GetWeatherByZipCode">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
Get one week weather forecast for a valid Zip Code(USA)
</wsdl:documentation>
<wsdl:input message="tns:GetWeatherByZipCodeHttpPostIn"/>
<wsdl:output message="tns:GetWeatherByZipCodeHttpPostOut"/>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
Get one week weather forecast for a place name(USA)
</wsdl:documentation>
<wsdl:input message="tns:GetWeatherByPlaceNameHttpPostIn"/>
<wsdl:output message="tns:GetWeatherByPlaceNameHttpPostOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WeatherForecastSoap" type="tns:WeatherForecastSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetWeatherByZipCode">
<soap:operation soapAction="http://www.webservicex.net/GetWeatherByZipCode" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<soap:operation soapAction="http://www.webservicex.net/GetWeatherByPlaceName" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="WeatherForecastSoap12" type="tns:WeatherForecastSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetWeatherByZipCode">
<soap12:operation soapAction="http://www.webservicex.net/GetWeatherByZipCode" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<soap12:operation soapAction="http://www.webservicex.net/GetWeatherByPlaceName" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="WeatherForecastHttpGet" type="tns:WeatherForecastHttpGet">
<http:binding verb="GET"/>
<wsdl:operation name="GetWeatherByZipCode">
<http:operation location="/GetWeatherByZipCode"/>
<wsdl:input>
<http:urlEncoded/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<http:operation location="/GetWeatherByPlaceName"/>
<wsdl:input>
<http:urlEncoded/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="WeatherForecastHttpPost" type="tns:WeatherForecastHttpPost">
<http:binding verb="POST"/>
<wsdl:operation name="GetWeatherByZipCode">
<http:operation location="/GetWeatherByZipCode"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<http:operation location="/GetWeatherByPlaceName"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WeatherForecast">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
Get one week weather forecast for valid zip code or Place name in USA
</wsdl:documentation>
<wsdl:port name="WeatherForecastSoap" binding="tns:WeatherForecastSoap">
<soap:address location="http://www.webservicex.net/WeatherForecast.asmx"/>
</wsdl:port>
<wsdl:port name="WeatherForecastSoap12" binding="tns:WeatherForecastSoap12">
<soap12:address location="http://www.webservicex.net/WeatherForecast.asmx"/>
</wsdl:port>
<wsdl:port name="WeatherForecastHttpGet" binding="tns:WeatherForecastHttpGet">
<http:address location="http://www.webservicex.net/WeatherForecast.asmx"/>
</wsdl:port>
<wsdl:port name="WeatherForecastHttpPost" binding="tns:WeatherForecastHttpPost">
<http:address location="http://www.webservicex.net/WeatherForecast.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我没有确定这两个例子之间的区别
为什么在第一个示例中,响应非常慢?问题在于发布方法

Endpoint.publish("http://192.168.1.13:8080/WS/TestSoap", new BalanceImp());
尝试在发布者的源应用程序中使用eclipse创建和发布web服务的向导。 此向导将通过添加

 <servlet>
    <display-name>Apache-Axis Servlet</display-name>
    <servlet-name>AxisServlet</servlet-name>
    <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/servlet/AxisServlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>*.jws</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>
  <servlet>
    <display-name>Axis Admin Servlet</display-name>
    <servlet-name>AdminServlet</servlet-name>
    <servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
    <load-on-startup>100</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>AdminServlet</servlet-name>
    <url-pattern>/servlet/AdminServlet</url-pattern>
  </servlet-mapping>
并将您添加到WEB-INF/文件下,如deploy.wsdd、undeploy.wsdd,当然还有service.wsdl,您将在其中找到您的

 <wsdlsoap:address location=".."/>
此外,部署时还将添加文件server-config.wsdd

输入那个地址,你就会得到服务


您的响应将是即时的。

第二次调用需要多长时间,可能您是在测量环境的设置时间,而不是调用本身?您将JAX-WS RI部署到什么环境中?您的设置是什么?感谢您的回复,我使用了包含liferay 5.2的tomcat v6,我认为响应时间是设置的,因为所有答案都是5分钟左右,但我没有发现下面的答案从何处解决了这个问题?是别的吗?