我正在使用Muhimbi Document Converter服务进行Windows Server上安装的文档转换。我们有2个负载均衡的应用服务器。我们正在使用Muhimbi提供的WSDL创建代理类,以便我们可以与转换服务器连接。 当我们请求转换时,SOAP请求会通过代理类在内部某个位置进行构架,然后发送到服务器。
当我们开始获取Socket读取超时异常时,我们开始跟踪转换服务器上的SOAP请求,发现SOAP请求来自2个不同的代理,有时User-Agent是 Axis2 < / strong>,有时用户代理是 JAX-WS RI 2.1.4-b01 。 有趣的事实是,只有User-Agent是 Axis2 的请求才会失败,并在每种情况下导致30秒钟左右的套接字读取超时异常。有趣的事实是,某种程度上它在2个负载平衡服务器上失败了,某种程度上1台服务器User-Agent是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请求的比较,希望能对您有所帮助
答案 0 :(得分:0)
关于我已经遇到的相同问题,我建议您在套接字读取超时的情况下使用wireshark或tcpdump跟踪您的请求和响应,这很可能是您在路由器,负载均衡器,防火墙上配置了一些网络。 ..导致在交换时丢弃某些数据包,从而导致socketReadTimeout。