Я использую Muhimbi Document Converter Service для конвертации документов, которая установлена на Windows Server. У нас есть 2 сервера приложений с балансировкой нагрузки. Мы используем WSDL, предоставленный Muhimbi, для создания прокси-классов, чтобы мы могли соединиться с сервером преобразования.
Когда мы запрашиваем преобразование, запрос SOAP создается внутри где-то через прокси-классы и отправляется на сервер.
Когда мы начали получать исключение тайм-аута чтения Socket, мы начали отслеживать SOAP-запросы, поступающие на сервер преобразования, и выяснили, что SOAP-запросы поступают от 2 разных агентов, иногда User-Agent - Axis2 иногда User-Agent - JAX-WS RI 2.1.4-b01 .
Интересным фактом является то, что только запросы, в которых User-Agent равен Axis2 , не выполняются и вызывают исключение тайм-аута чтения сокета около 30 секунд в каждом случае. Интересен тот факт, что почему-то происходит сбой на 1 из 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, любая помощь будет признательна