【发布时间】:2018-09-06 09:03:16
【问题描述】:
我正在使用安装在 Windows 服务器上的 Muhimbi 文档转换器服务进行文档转换。我们有 2 个负载平衡的应用程序服务器。我们正在使用 Muhimbi 提供的 WSDL 来创建代理类,以便我们可以连接到转换服务器。 当我们请求转换时,SOAP 请求会通过代理类在内部某处构建并发送到服务器。
当我们开始收到 Socket 读取超时异常时,我们开始跟踪来自转换服务器的 SOAP 请求,我们发现 SOAP 请求来自 2 个不同的代理,有时用户代理是 Axis2 有时用户代理是 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 请求的比较,任何帮助将不胜感激
【问题讨论】:
标签: java web-services soap jax-ws axis2