SOAP请求 - 套接字读取超时

问题描述 投票:0回答:1

我正在使用安装在Windows Server上的文档转换Muhimbi文档转换器服务。我们有2个负载均衡的应用服务器。我们使用Muhimbi提供的WSDL来创建代理类,以便我们可以与转换服务器连接。当我们请求转换时,SOAP请求通过代理类在某处内部构建,并发送到服务器。

当我们开始获取Socket读取超时异常时,我们开始跟踪转发服务器上发出的SOAP请求,我们发现SOAP请求来自2个不同的代理,有时User-Agent是Axis2,有时User-Agent是JAX -WS RI 2.1.4-b01。这里有趣的事实只是用户代理是Axis2失败的请求,并且在每种情况下导致套接字读取超时异常大约30秒。有趣的事实是,不知何故,它在2个负载平衡服务器中失败,不知何故,1个服务器用户代理是Axis2,而在另一个服务器上它的JAX-WS RI

我需要帮助来确定如何确定用户代理是否应该是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; 
        }

下面是生成的代理类和我正在使用的代理类:

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
    ;

}

另一课:

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);
    }

}

我还附上成功的SOAP请求的比较,任何帮助将不胜感激

SOAP REQUEST COMPARISON

java web-services soap jax-ws axis2
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.