简体   繁体   English

SOAP请求-套接字读取超时

[英]SOAP Request - Socket Read Timeout

I am using Muhimbi Document Converter Service for Document Conversion which is installed on a Windows Server. 我正在使用Muhimbi Document Converter服务进行Windows Server上安装的文档转换。 We have 2 Application servers which are load balanced. 我们有2个负载均衡的应用服务器。 We are using the WSDL provided by the Muhimbi to create proxy classes so that we can connect with the conversion server. 我们正在使用Muhimbi提供的WSDL创建代理类,以便我们可以与转换服务器连接。 When we request for a conversion the SOAP request is framed internally somewhere through the proxy classes and is sent to the server. 当我们请求转换时,SOAP请求通过代理类在内部某个位置进行构架,然后发送到服务器。

When we started getting the Socket read timeout exception we started tracing the SOAP requests that are coming on the Conversion server and we found out the SOAP requests are coming from 2 different agents, sometimes the User-Agent is Axis2 sometimes the User-Agent is JAX-WS RI 2.1.4-b01 . 当我们开始获取Socket读取超时异常时,我们开始跟踪转换服务器上的SOAP请求,发现SOAP请求来自2个不同的代理,有时User-Agent是Axis2,有时User-Agent是JAX -WS RI 2.1.4-b01 The interesting fact here is only the requests where User-Agent is Axis2 are failing and causing a socket read timeout exception around 30 seconds in each case. 有趣的事实是,只有User-Agent是Axis2的请求都失败,并且在每种情况下都会导致30秒钟左右的套接字读取超时异常。 The interesting fact is that somehow it's failing on 1 out of 2 loads balanced server, somehow one 1 server User-Agent is Axis2 and on another server its JAX-WS RI 有趣的事实是,它在2个负载平衡服务器中的1个以某种方式失败,以某种方式1台服务器User-Agent是Axis2,在另一台服务器上是JAX-WS RI

I need help to identify that how its getting decided that whether user-agent should be axi2 or JAX-WS RI and is there any configuration at the JBOSS level which will make the connection alive until the response comes back. 我需要帮助来确定其如何决定用户代理应该是axi2还是JAX-WS RI,并且在JBOSS级别上是否有任何配置可以使连接保持活动状态直到响应返回。

public static DocumentConverterService getDocumentServiceInstance(){
        // ** Initialise Web Service
        if(dcs != null){
            return dcs;
        } else{
            DocumentConverterService_Service dcss;
            try {
                /*dcss = new DocumentConverterService_Service(
                        new URL(DOCUMENTCONVERTERSERVICE_WSDL_LOCATION), 
                        new QName("http://tempuri.org/", "DocumentConverterService"));*/
                dcss = new DocumentConverterService_Service(
                        new URL(MUHIMBI_URL), 
                        new QName("http://tempuri.org/", "DocumentConverterService"));

            dcs = dcss.getBasicHttpBindingDocumentConverterService();
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return dcs;
        }

    }
    public static String getCoverPagePDF(MuhimbiParam param){
            try { 

                    long startTime = System.currentTimeMillis();
                    String sourceDocumentPath = param.getCoverPagePath(); 
                    File file = new File(sourceDocumentPath); 
                    String pgNmInd = param.getPageNum();
                    //param.setPageNum("N");
                    String fileName = param.getFileNm();
                    String fileExt = getFileExtension(file); 
                    System.out.println("Header :: " + param.getHeaderReq());
                    System.out.println("Footer :: " + param.getFooterReq());
                    //System.out.println("Converting file " + sourceDocumentPath + " :: " +  System.nanoTime()); 
                    // ** Initialize Web Service 
                    System.out.println("Muhimbi URL :: " + MUHIMBI_URL);
                    DocumentConverterService dcs = getDocumentServiceInstance(); 
                   // System.out.println("Web Service Initialized ");
                      // ** Read source file from disk 
                      byte[] fileContent = readFile(sourceDocumentPath); 
                      //System.out.println(" Read source file from disk  ");
                      // ** Converting the file 
                      OpenOptions openOptions = getOpenOptions(fileName, fileExt); 
                     // System.out.println("Initialized Open Options");
                      param.setFooterType(FOOTER_TYPE_MULTI);
                      ConversionSettings conversionSettings = getConversionSettings(param); 
                      //System.out.println("Initialized Conversion Settings");
                      byte[] convertedFile = dcs.convert(fileContent, openOptions, conversionSettings); // place where we call method of proxy class which creates SOAP requests somewhere to contact the conversion server.
                      System.out.println("Cover Page Byte Created at :: " + System.nanoTime());
                      // ** Writing converted file to file system 
                      //String destinationDocumentPath = getPDFDocumentPath(param); 
                      String rptNm = "";
                      /*if(param.getRptNm() != null) {
                          rptNm = param.getRptNm() + "-" + System.currentTimeMillis() + ".pdf";
                      }else {
                          rptNm = param.getFileNm() + "-" + System.currentTimeMillis() + ".pdf";
                      }*/
                      if(param.getRptNm() != null) {
                          rptNm = param.getRptNm()+".pdf";
                      }else {
                          rptNm = param.getFileNm()+".pdf";
                      }
                      String destinationDocumentPath = param.getTempPath()+rptNm;
                      writeFile(convertedFile, destinationDocumentPath); 
                      System.out.println("File converted sucessfully to " + destinationDocumentPath);
                      long endTime = System.currentTimeMillis();
                      System.out.println("Time taken to create a Cover Page is :: " + (endTime - startTime)/1000);
                      param.setPageNum(pgNmInd);
                      return destinationDocumentPath;

                } catch (IOException e) { 
                  System.out.println(e.getMessage()); 
                } catch (DocumentConverterServiceConvertWebServiceFaultExceptionFaultFaultMessage e) { 
                  printException(e.getFaultInfo()); 
                }
            return null; 
        }

Below are the proxy classes which got generated and which i am using: 以下是生成的代理类以及我正在使用的代理类:

package com.honeywell.muhimbi.ws;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;


/**
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.1.6 in JDK 6
 * Generated source version: 2.1
 * 
 */
@WebService(name = "DocumentConverterService", targetNamespace = "http://services.muhimbi.com/2009/10/06")
@XmlSeeAlso({
    ObjectFactory.class
})
public interface DocumentConverterService {


    /**
     * 
     * @param conversionSettings
     * @param sourceFile
     * @param openOptions
     * @return
     *     returns byte[]
     * @throws DocumentConverterServiceConvertWebServiceFaultExceptionFaultFaultMessage
     */
    @WebMethod(operationName = "Convert", action = "http://services.muhimbi.com/2009/10/06/DocumentConverterService/Convert")
    @WebResult(name = "ConvertResult", targetNamespace = "http://services.muhimbi.com/2009/10/06")
    @RequestWrapper(localName = "Convert", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.Convert")
    @ResponseWrapper(localName = "ConvertResponse", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.ConvertResponse")
    public byte[] convert(
        @WebParam(name = "sourceFile", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        byte[] sourceFile,
        @WebParam(name = "openOptions", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        OpenOptions openOptions,
        @WebParam(name = "conversionSettings", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        ConversionSettings conversionSettings)
        throws DocumentConverterServiceConvertWebServiceFaultExceptionFaultFaultMessage
    ;

    /**
     * 
     * @param conversionSettings
     * @param sourceFile
     * @param openOptions
     * @return
     *     returns byte[]
     * @throws DocumentConverterServiceApplyWatermarkWebServiceFaultExceptionFaultFaultMessage
     */
    @WebMethod(operationName = "ApplyWatermark", action = "http://services.muhimbi.com/2009/10/06/DocumentConverterService/ApplyWatermark")
    @WebResult(name = "ApplyWatermarkResult", targetNamespace = "http://services.muhimbi.com/2009/10/06")
    @RequestWrapper(localName = "ApplyWatermark", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.ApplyWatermark")
    @ResponseWrapper(localName = "ApplyWatermarkResponse", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.ApplyWatermarkResponse")
    public byte[] applyWatermark(
        @WebParam(name = "sourceFile", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        byte[] sourceFile,
        @WebParam(name = "openOptions", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        OpenOptions openOptions,
        @WebParam(name = "conversionSettings", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        ConversionSettings conversionSettings)
        throws DocumentConverterServiceApplyWatermarkWebServiceFaultExceptionFaultFaultMessage
    ;

    /**
     * 
     * @param conversionSettings
     * @param sourceFile
     * @param openOptions
     * @return
     *     returns byte[]
     * @throws DocumentConverterServiceApplySecurityWebServiceFaultExceptionFaultFaultMessage
     */
    @WebMethod(operationName = "ApplySecurity", action = "http://services.muhimbi.com/2009/10/06/DocumentConverterService/ApplySecurity")
    @WebResult(name = "ApplySecurityResult", targetNamespace = "http://services.muhimbi.com/2009/10/06")
    @RequestWrapper(localName = "ApplySecurity", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.ApplySecurity")
    @ResponseWrapper(localName = "ApplySecurityResponse", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.ApplySecurityResponse")
    public byte[] applySecurity(
        @WebParam(name = "sourceFile", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        byte[] sourceFile,
        @WebParam(name = "openOptions", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        OpenOptions openOptions,
        @WebParam(name = "conversionSettings", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        ConversionSettings conversionSettings)
        throws DocumentConverterServiceApplySecurityWebServiceFaultExceptionFaultFaultMessage
    ;

    /**
     * 
     * @param conversionSettings
     * @param sourceFile
     * @param openOptions
     * @return
     *     returns byte[]
     * @throws DocumentConverterServiceProcessChangesWebServiceFaultExceptionFaultFaultMessage
     */
    @WebMethod(operationName = "ProcessChanges", action = "http://services.muhimbi.com/2009/10/06/DocumentConverterService/ProcessChanges")
    @WebResult(name = "ProcessChangesResult", targetNamespace = "http://services.muhimbi.com/2009/10/06")
    @RequestWrapper(localName = "ProcessChanges", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.ProcessChanges")
    @ResponseWrapper(localName = "ProcessChangesResponse", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.ProcessChangesResponse")
    public byte[] processChanges(
        @WebParam(name = "sourceFile", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        byte[] sourceFile,
        @WebParam(name = "openOptions", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        OpenOptions openOptions,
        @WebParam(name = "conversionSettings", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        ConversionSettings conversionSettings)
        throws DocumentConverterServiceProcessChangesWebServiceFaultExceptionFaultFaultMessage
    ;

    /**
     * 
     * @param options
     * @return
     *     returns com.muhimbi.ws.BatchResults
     * @throws DocumentConverterServiceProcessBatchWebServiceFaultExceptionFaultFaultMessage
     */
    @WebMethod(operationName = "ProcessBatch", action = "http://services.muhimbi.com/2009/10/06/DocumentConverterService/ProcessBatch")
    @WebResult(name = "ProcessBatchResult", targetNamespace = "http://services.muhimbi.com/2009/10/06")
    @RequestWrapper(localName = "ProcessBatch", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.ProcessBatch")
    @ResponseWrapper(localName = "ProcessBatchResponse", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.ProcessBatchResponse")
    public BatchResults processBatch(
        @WebParam(name = "options", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        ProcessingOptions options)
        throws DocumentConverterServiceProcessBatchWebServiceFaultExceptionFaultFaultMessage
    ;

    /**
     * 
     * @return
     *     returns com.muhimbi.ws.Configuration
     * @throws DocumentConverterServiceGetConfigurationWebServiceFaultExceptionFaultFaultMessage
     */
    @WebMethod(operationName = "GetConfiguration", action = "http://services.muhimbi.com/2009/10/06/DocumentConverterService/GetConfiguration")
    @WebResult(name = "GetConfigurationResult", targetNamespace = "http://services.muhimbi.com/2009/10/06")
    @RequestWrapper(localName = "GetConfiguration", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.GetConfiguration")
    @ResponseWrapper(localName = "GetConfigurationResponse", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.GetConfigurationResponse")
    public Configuration getConfiguration()
        throws DocumentConverterServiceGetConfigurationWebServiceFaultExceptionFaultFaultMessage
    ;

    /**
     * 
     * @param convertersToDiagnose
     * @return
     *     returns com.muhimbi.ws.Diagnostics
     * @throws DocumentConverterServiceGetDiagnosticsWebServiceFaultExceptionFaultFaultMessage
     */
    @WebMethod(operationName = "GetDiagnostics", action = "http://services.muhimbi.com/2009/10/06/DocumentConverterService/GetDiagnostics")
    @WebResult(name = "GetDiagnosticsResult", targetNamespace = "http://services.muhimbi.com/2009/10/06")
    @RequestWrapper(localName = "GetDiagnostics", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.GetDiagnostics")
    @ResponseWrapper(localName = "GetDiagnosticsResponse", targetNamespace = "http://services.muhimbi.com/2009/10/06", className = "com.muhimbi.ws.GetDiagnosticsResponse")
    public Diagnostics getDiagnostics(
        @WebParam(name = "convertersToDiagnose", targetNamespace = "http://services.muhimbi.com/2009/10/06")
        ArrayOfDiagnosticRequestItem convertersToDiagnose)
        throws DocumentConverterServiceGetDiagnosticsWebServiceFaultExceptionFaultFaultMessage
    ;

}

Another class: 另一类:

package com.honeywell.muhimbi.ws;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;

import com.honeywell.cdd.CDDConstants;


/**
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.1.6 in JDK 6
 * Generated source version: 2.1
 * 
 */

/*@WebServiceClient(name = "DocumentConverterService", targetNamespace = "http://tempuri.org/", wsdlLocation = "http://ie3bvwisop155.global.ds.honeywell.com:41734/Muhimbi.DocumentConverter.WebService/?wsdl")
*/public class DocumentConverterService_Service
    extends Service
{
    private static String MUHIMBI_URL;


    /**
     * @param mUHIMBI_URL the mUHIMBI_URL to set
     */
    public void setMUHIMBI_URL(String muhimbi_url) {
        MUHIMBI_URL = muhimbi_url;
    }

    private final static URL DOCUMENTCONVERTERSERVICE_WSDL_LOCATION;
    private final static Logger logger = Logger.getLogger(com.honeywell.muhimbi.ws.DocumentConverterService_Service.class.getName());
    private final static String MUHIMBI_LOCAL = "http://LOCAL_SERVER:41734/Muhimbi.DocumentConverter.WebService/?wsdl";
    private final static String MUHIMBI_PROD = "http://PROD_SERVER:41734/Muhimbi.DocumentConverter.WebService/?wsdl";
    static {
        URL url = null;
        try {
            URL baseUrl;
            System.out.println("Habitat is :: " + System.getProperty("HABITAT"));
            String habitat = System.getProperty("HABITAT").toString();
            baseUrl = com.honeywell.muhimbi.ws.DocumentConverterService_Service.class.getResource(".");
            if(habitat.equalsIgnoreCase(CDDConstants.ERS_DEV_JBOSS6) || habitat.equalsIgnoreCase(CDDConstants.ERS_TEST_JBOSS6)) {
                url = new URL(baseUrl, MUHIMBI_LOCAL);
            }else {
                url = new URL(baseUrl, MUHIMBI_PROD);
                //url = new URL(baseUrl, MUHIMBI_LOCAL);
            }
            System.out.println("Muhimbi URL Successfully Initialised :: " + url.toString());
        } catch (MalformedURLException e) {
            logger.warning("Failed to create URL for the wsdl Location: " + MUHIMBI_URL + " , retrying as a local file");
            logger.warning(e.getMessage());
        }
        DOCUMENTCONVERTERSERVICE_WSDL_LOCATION = url;
    }

    public DocumentConverterService_Service(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public DocumentConverterService_Service() {
        super(DOCUMENTCONVERTERSERVICE_WSDL_LOCATION, new QName("http://tempuri.org/", "DocumentConverterService"));
    }

    /**
     * 
     * @return
     *     returns DocumentConverterService
     */
    @WebEndpoint(name = "BasicHttpBinding_DocumentConverterService")
    public DocumentConverterService getBasicHttpBindingDocumentConverterService() {
        return super.getPort(new QName("http://tempuri.org/", "BasicHttpBinding_DocumentConverterService"), DocumentConverterService.class);
    }

    /**
     * 
     * @param features
     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.
     * @return
     *     returns DocumentConverterService
     */
    @WebEndpoint(name = "BasicHttpBinding_DocumentConverterService")
    public DocumentConverterService getBasicHttpBindingDocumentConverterService(WebServiceFeature... features) {
        return super.getPort(new QName("http://tempuri.org/", "BasicHttpBinding_DocumentConverterService"), DocumentConverterService.class, features);
    }

}

I am also attaching the comparison of the successful SOAP requests , any help would be appreciated 我还要附上成功的SOAP请求的比较,任何帮助将不胜感激

SOAP请求比较

关于我已经遇到的同一问题,我建议您在套接字读取超时的情况下使用wireshark或tcpdump跟踪您的请求和响应,这很可能是您在路由器,负载均衡器,防火墙等上进行了一些网络配置。导致在交换时丢弃某些数据包,从而导致socketReadTimeout。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM