正在实施的项目是一个数据中心项目,客户要求写一个通用的数据访问接口,可以兼容现有与以后的应用访问后端不同的数据库。考虑到现有的应用有java、visual basic与C++,而我们实施的应用既有java也有.net,需要访问的数据库既有DB2、Oracle也有SQL Server,所以用web service来提供数据访问。参考微软的Data Access Application Block,做了一个通用的服务,前端传送SQL语句给后端服务,服务返回执行后的XML串。使用.net客户端访问该服务,一切功能正常。但在使用java客户端访问时,却出现了问题。
我采用Eclipse平台开发java应用,找不到直接调用web service的插件,采用axis生成java包后在应用在调用。在应用中当返回的字串大小超过64K时,却出现org.xml.sax.SAXParseException,提示“分析器已达到由应用程序设置的实体扩展限制”,因为对java不是很熟悉,找了好久都找不到原因,不知各位有没有好的解决方法。
代码与提示信息如下:
1、生成java包语句:
java -classpath commons-logging.jar;log4j-1.2.8.jar;wsdl4j.jar;axis.jar;commons-discovery.jar;jaxrpc.jar;saaj.jar org.apache.axis.wsdl.WSDL2Java -p DataService http://localhost/DataService/DBService.asmx?wsdl
DBService.java的代码:
/**
* DBService.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package DataService;
public interface DBService extends javax.xml.rpc.Service {
// 通用数据访问服务
public java.lang.String getDBServiceSoapAddress();
public DataService.DBServiceSoap getDBServiceSoap() throws javax.xml.rpc.ServiceException;
public DataService.DBServiceSoap getDBServiceSoap(java.net.URL portAddress) throws javax.xml.rpc.ServiceException;
}
* DBService.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package DataService;
public interface DBService extends javax.xml.rpc.Service {
// 通用数据访问服务
public java.lang.String getDBServiceSoapAddress();
public DataService.DBServiceSoap getDBServiceSoap() throws javax.xml.rpc.ServiceException;
public DataService.DBServiceSoap getDBServiceSoap(java.net.URL portAddress) throws javax.xml.rpc.ServiceException;
}
DBServiceLocator.java的代码:
/**
* DBServiceLocator.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package DataService;
public class DBServiceLocator extends org.apache.axis.client.Service implements DataService.DBService {
// 通锟斤拷锟斤拷莘锟斤拷史锟斤拷锟�
// Use to get a proxy class for DBServiceSoap
private final java.lang.String DBServiceSoap_address = "http://180.1.3.28/DataService/DBService.asmx";
public java.lang.String getDBServiceSoapAddress() {
return DBServiceSoap_address;
}
// The WSDD service name defaults to the port name.
private java.lang.String DBServiceSoapWSDDServiceName = "DBServiceSoap";
public java.lang.String getDBServiceSoapWSDDServiceName() {
return DBServiceSoapWSDDServiceName;
}
public void setDBServiceSoapWSDDServiceName(java.lang.String name) {
DBServiceSoapWSDDServiceName = name;
}
public DataService.DBServiceSoap getDBServiceSoap() throws javax.xml.rpc.ServiceException {
java.net.URL endpoint;
try {
endpoint = new java.net.URL(DBServiceSoap_address);
}
catch (java.net.MalformedURLException e) {
throw new javax.xml.rpc.ServiceException(e);
}
return getDBServiceSoap(endpoint);
}
public DataService.DBServiceSoap getDBServiceSoap(java.net.URL portAddress) throws javax.xml.rpc.ServiceException {
try {
DataService.DBServiceSoapStub _stub = new DataService.DBServiceSoapStub(portAddress, this);
_stub.setPortName(getDBServiceSoapWSDDServiceName());
return _stub;
}
catch (org.apache.axis.AxisFault e) {
return null;
}
}
/**
* For the given interface, get the stub implementation.
* If this service has no port for the given interface,
* then ServiceException is thrown.
*/
public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
try {
if (DataService.DBServiceSoap.class.isAssignableFrom(serviceEndpointInterface)) {
DataService.DBServiceSoapStub _stub = new DataService.DBServiceSoapStub(new java.net.URL(DBServiceSoap_address), this);
_stub.setPortName(getDBServiceSoapWSDDServiceName());
return _stub;
}
}
catch (java.lang.Throwable t) {
throw new javax.xml.rpc.ServiceException(t);
}
throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName()));
}
/**
* For the given interface, get the stub implementation.
* If this service has no port for the given interface,
* then ServiceException is thrown.
*/
public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
if (portName == null) {
return getPort(serviceEndpointInterface);
}
String inputPortName = portName.getLocalPart();
if ("DBServiceSoap".equals(inputPortName)) {
return getDBServiceSoap();
}
else {
java.rmi.Remote _stub = getPort(serviceEndpointInterface);
((org.apache.axis.client.Stub) _stub).setPortName(portName);
return _stub;
}
}
public javax.xml.namespace.QName getServiceName() {
return new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "DBService");
}
private java.util.HashSet ports = null;
public java.util.Iterator getPorts() {
if (ports == null) {
ports = new java.util.HashSet();
ports.add(new javax.xml.namespace.QName("DBServiceSoap"));
}
return ports.iterator();
}
}
* DBServiceLocator.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package DataService;
public class DBServiceLocator extends org.apache.axis.client.Service implements DataService.DBService {
// 通锟斤拷锟斤拷莘锟斤拷史锟斤拷锟�
// Use to get a proxy class for DBServiceSoap
private final java.lang.String DBServiceSoap_address = "http://180.1.3.28/DataService/DBService.asmx";
public java.lang.String getDBServiceSoapAddress() {
return DBServiceSoap_address;
}
// The WSDD service name defaults to the port name.
private java.lang.String DBServiceSoapWSDDServiceName = "DBServiceSoap";
public java.lang.String getDBServiceSoapWSDDServiceName() {
return DBServiceSoapWSDDServiceName;
}
public void setDBServiceSoapWSDDServiceName(java.lang.String name) {
DBServiceSoapWSDDServiceName = name;
}
public DataService.DBServiceSoap getDBServiceSoap() throws javax.xml.rpc.ServiceException {
java.net.URL endpoint;
try {
endpoint = new java.net.URL(DBServiceSoap_address);
}
catch (java.net.MalformedURLException e) {
throw new javax.xml.rpc.ServiceException(e);
}
return getDBServiceSoap(endpoint);
}
public DataService.DBServiceSoap getDBServiceSoap(java.net.URL portAddress) throws javax.xml.rpc.ServiceException {
try {
DataService.DBServiceSoapStub _stub = new DataService.DBServiceSoapStub(portAddress, this);
_stub.setPortName(getDBServiceSoapWSDDServiceName());
return _stub;
}
catch (org.apache.axis.AxisFault e) {
return null;
}
}
/**
* For the given interface, get the stub implementation.
* If this service has no port for the given interface,
* then ServiceException is thrown.
*/
public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
try {
if (DataService.DBServiceSoap.class.isAssignableFrom(serviceEndpointInterface)) {
DataService.DBServiceSoapStub _stub = new DataService.DBServiceSoapStub(new java.net.URL(DBServiceSoap_address), this);
_stub.setPortName(getDBServiceSoapWSDDServiceName());
return _stub;
}
}
catch (java.lang.Throwable t) {
throw new javax.xml.rpc.ServiceException(t);
}
throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName()));
}
/**
* For the given interface, get the stub implementation.
* If this service has no port for the given interface,
* then ServiceException is thrown.
*/
public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
if (portName == null) {
return getPort(serviceEndpointInterface);
}
String inputPortName = portName.getLocalPart();
if ("DBServiceSoap".equals(inputPortName)) {
return getDBServiceSoap();
}
else {
java.rmi.Remote _stub = getPort(serviceEndpointInterface);
((org.apache.axis.client.Stub) _stub).setPortName(portName);
return _stub;
}
}
public javax.xml.namespace.QName getServiceName() {
return new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "DBService");
}
private java.util.HashSet ports = null;
public java.util.Iterator getPorts() {
if (ports == null) {
ports = new java.util.HashSet();
ports.add(new javax.xml.namespace.QName("DBServiceSoap"));
}
return ports.iterator();
}
}
/**
* DBServiceSoap.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package DataService;
public interface DBServiceSoap extends java.rmi.Remote {
// Test only
public java.lang.String helloWorld() throws java.rmi.RemoteException;
// 执行SQL语句或存储过程,不返回结果集
public int executeNonQuery(java.lang.String logicalName, java.lang.String commandText, boolean isStoreProcedure, java.lang.String paraList) throws java.rmi.RemoteException;
// 执行语句并返回结果集
public java.lang.String executeResult(java.lang.String logicalName, java.lang.String commandText, boolean isStoreProcedure, java.lang.String paraList) throws java.rmi.RemoteException;
}
* DBServiceSoap.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package DataService;
public interface DBServiceSoap extends java.rmi.Remote {
// Test only
public java.lang.String helloWorld() throws java.rmi.RemoteException;
// 执行SQL语句或存储过程,不返回结果集
public int executeNonQuery(java.lang.String logicalName, java.lang.String commandText, boolean isStoreProcedure, java.lang.String paraList) throws java.rmi.RemoteException;
// 执行语句并返回结果集
public java.lang.String executeResult(java.lang.String logicalName, java.lang.String commandText, boolean isStoreProcedure, java.lang.String paraList) throws java.rmi.RemoteException;
}
DBServiceSoapStub.java的代码:
/**
* DBServiceSoapStub.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package DataService;
public class DBServiceSoapStub extends org.apache.axis.client.Stub implements DataService.DBServiceSoap {
private java.util.Vector cachedSerClasses = new java.util.Vector();
private java.util.Vector cachedSerQNames = new java.util.Vector();
private java.util.Vector cachedSerFactories = new java.util.Vector();
private java.util.Vector cachedDeserFactories = new java.util.Vector();
static org.apache.axis.description.OperationDesc [] _operations;
static {
_operations = new org.apache.axis.description.OperationDesc[3];
org.apache.axis.description.OperationDesc oper;
oper = new org.apache.axis.description.OperationDesc();
oper.setName("HelloWorld");
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
oper.setReturnClass(java.lang.String.class);
oper.setReturnQName(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "HelloWorldResult"));
oper.setStyle(org.apache.axis.enum.Style.WRAPPED);
oper.setUse(org.apache.axis.enum.Use.LITERAL);
_operations[0] = oper;
oper = new org.apache.axis.description.OperationDesc();
oper.setName("ExecuteNonQuery");
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "logicalName"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "commandText"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "isStoreProcedure"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean"), boolean.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "paraList"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"));
oper.setReturnClass(int.class);
oper.setReturnQName(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "ExecuteNonQueryResult"));
oper.setStyle(org.apache.axis.enum.Style.WRAPPED);
oper.setUse(org.apache.axis.enum.Use.LITERAL);
_operations[1] = oper;
oper = new org.apache.axis.description.OperationDesc();
oper.setName("ExecuteResult");
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "logicalName"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "commandText"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "isStoreProcedure"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean"), boolean.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "paraList"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
oper.setReturnClass(java.lang.String.class);
oper.setReturnQName(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "ExecuteResultResult"));
oper.setStyle(org.apache.axis.enum.Style.WRAPPED);
oper.setUse(org.apache.axis.enum.Use.LITERAL);
_operations[2] = oper;
}
public DBServiceSoapStub() throws org.apache.axis.AxisFault {
this(null);
}
public DBServiceSoapStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
this(service);
super.cachedEndpoint = endpointURL;
}
public DBServiceSoapStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
if (service == null) {
super.service = new org.apache.axis.client.Service();
} else {
super.service = service;
}
}
private org.apache.axis.client.Call createCall() throws java.rmi.RemoteException {
try {
org.apache.axis.client.Call _call =
(org.apache.axis.client.Call) super.service.createCall();
if (super.maintainSessionSet) {
_call.setMaintainSession(super.maintainSession);
}
if (super.cachedUsername != null) {
_call.setUsername(super.cachedUsername);
}
if (super.cachedPassword != null) {
_call.setPassword(super.cachedPassword);
}
if (super.cachedEndpoint != null) {
_call.setTargetEndpointAddress(super.cachedEndpoint);
}
if (super.cachedTimeout != null) {
_call.setTimeout(super.cachedTimeout);
}
if (super.cachedPortName != null) {
_call.setPortName(super.cachedPortName);
}
java.util.Enumeration keys = super.cachedProperties.keys();
while (keys.hasMoreElements()) {
java.lang.String key = (java.lang.String) keys.nextElement();
_call.setProperty(key, super.cachedProperties.get(key));
}
return _call;
}
catch (java.lang.Throwable t) {
throw new org.apache.axis.AxisFault("Failure trying to get the Call object", t);
}
}
public java.lang.String helloWorld() throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[0]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("http://www.gds-china.com/DataService/HelloWorld");
_call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "HelloWorld"));
setRequestHeaders(_call);
setAttachments(_call);
java.lang.Object _resp = _call.invoke(new java.lang.Object[] {});
if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException)_resp;
}
else {
extractAttachments(_call);
try {
return (java.lang.String) _resp;
} catch (java.lang.Exception _exception) {
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
}
}
}
public int executeNonQuery(java.lang.String logicalName, java.lang.String commandText, boolean isStoreProcedure, java.lang.String paraList) throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[1]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("http://www.gds-china.com/DataService/ExecuteNonQuery");
_call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "ExecuteNonQuery"));
setRequestHeaders(_call);
setAttachments(_call);
java.lang.Object _resp = _call.invoke(new java.lang.Object[] {logicalName, commandText, new java.lang.Boolean(isStoreProcedure), paraList});
if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException)_resp;
}
else {
extractAttachments(_call);
try {
return ((java.lang.Integer) _resp).intValue();
} catch (java.lang.Exception _exception) {
return ((java.lang.Integer) org.apache.axis.utils.JavaUtils.convert(_resp, int.class)).intValue();
}
}
}
public java.lang.String executeResult(java.lang.String logicalName, java.lang.String commandText, boolean isStoreProcedure, java.lang.String paraList) throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[2]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("http://www.gds-china.com/DataService/ExecuteResult");
_call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "ExecuteResult"));
setRequestHeaders(_call);
setAttachments(_call);
java.lang.Object _resp = _call.invoke(new java.lang.Object[] {logicalName, commandText, new java.lang.Boolean(isStoreProcedure), paraList});
if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException)_resp;
}
else {
extractAttachments(_call);
try {
return (java.lang.String) _resp;
} catch (java.lang.Exception _exception) {
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
}
}
}
}
* DBServiceSoapStub.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package DataService;
public class DBServiceSoapStub extends org.apache.axis.client.Stub implements DataService.DBServiceSoap {
private java.util.Vector cachedSerClasses = new java.util.Vector();
private java.util.Vector cachedSerQNames = new java.util.Vector();
private java.util.Vector cachedSerFactories = new java.util.Vector();
private java.util.Vector cachedDeserFactories = new java.util.Vector();
static org.apache.axis.description.OperationDesc [] _operations;
static {
_operations = new org.apache.axis.description.OperationDesc[3];
org.apache.axis.description.OperationDesc oper;
oper = new org.apache.axis.description.OperationDesc();
oper.setName("HelloWorld");
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
oper.setReturnClass(java.lang.String.class);
oper.setReturnQName(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "HelloWorldResult"));
oper.setStyle(org.apache.axis.enum.Style.WRAPPED);
oper.setUse(org.apache.axis.enum.Use.LITERAL);
_operations[0] = oper;
oper = new org.apache.axis.description.OperationDesc();
oper.setName("ExecuteNonQuery");
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "logicalName"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "commandText"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "isStoreProcedure"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean"), boolean.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "paraList"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"));
oper.setReturnClass(int.class);
oper.setReturnQName(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "ExecuteNonQueryResult"));
oper.setStyle(org.apache.axis.enum.Style.WRAPPED);
oper.setUse(org.apache.axis.enum.Use.LITERAL);
_operations[1] = oper;
oper = new org.apache.axis.description.OperationDesc();
oper.setName("ExecuteResult");
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "logicalName"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "commandText"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "isStoreProcedure"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean"), boolean.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "paraList"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
oper.setReturnClass(java.lang.String.class);
oper.setReturnQName(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "ExecuteResultResult"));
oper.setStyle(org.apache.axis.enum.Style.WRAPPED);
oper.setUse(org.apache.axis.enum.Use.LITERAL);
_operations[2] = oper;
}
public DBServiceSoapStub() throws org.apache.axis.AxisFault {
this(null);
}
public DBServiceSoapStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
this(service);
super.cachedEndpoint = endpointURL;
}
public DBServiceSoapStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
if (service == null) {
super.service = new org.apache.axis.client.Service();
} else {
super.service = service;
}
}
private org.apache.axis.client.Call createCall() throws java.rmi.RemoteException {
try {
org.apache.axis.client.Call _call =
(org.apache.axis.client.Call) super.service.createCall();
if (super.maintainSessionSet) {
_call.setMaintainSession(super.maintainSession);
}
if (super.cachedUsername != null) {
_call.setUsername(super.cachedUsername);
}
if (super.cachedPassword != null) {
_call.setPassword(super.cachedPassword);
}
if (super.cachedEndpoint != null) {
_call.setTargetEndpointAddress(super.cachedEndpoint);
}
if (super.cachedTimeout != null) {
_call.setTimeout(super.cachedTimeout);
}
if (super.cachedPortName != null) {
_call.setPortName(super.cachedPortName);
}
java.util.Enumeration keys = super.cachedProperties.keys();
while (keys.hasMoreElements()) {
java.lang.String key = (java.lang.String) keys.nextElement();
_call.setProperty(key, super.cachedProperties.get(key));
}
return _call;
}
catch (java.lang.Throwable t) {
throw new org.apache.axis.AxisFault("Failure trying to get the Call object", t);
}
}
public java.lang.String helloWorld() throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[0]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("http://www.gds-china.com/DataService/HelloWorld");
_call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "HelloWorld"));
setRequestHeaders(_call);
setAttachments(_call);
java.lang.Object _resp = _call.invoke(new java.lang.Object[] {});
if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException)_resp;
}
else {
extractAttachments(_call);
try {
return (java.lang.String) _resp;
} catch (java.lang.Exception _exception) {
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
}
}
}
public int executeNonQuery(java.lang.String logicalName, java.lang.String commandText, boolean isStoreProcedure, java.lang.String paraList) throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[1]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("http://www.gds-china.com/DataService/ExecuteNonQuery");
_call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "ExecuteNonQuery"));
setRequestHeaders(_call);
setAttachments(_call);
java.lang.Object _resp = _call.invoke(new java.lang.Object[] {logicalName, commandText, new java.lang.Boolean(isStoreProcedure), paraList});
if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException)_resp;
}
else {
extractAttachments(_call);
try {
return ((java.lang.Integer) _resp).intValue();
} catch (java.lang.Exception _exception) {
return ((java.lang.Integer) org.apache.axis.utils.JavaUtils.convert(_resp, int.class)).intValue();
}
}
}
public java.lang.String executeResult(java.lang.String logicalName, java.lang.String commandText, boolean isStoreProcedure, java.lang.String paraList) throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[2]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("http://www.gds-china.com/DataService/ExecuteResult");
_call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("http://www.gds-china.com/DataService/", "ExecuteResult"));
setRequestHeaders(_call);
setAttachments(_call);
java.lang.Object _resp = _call.invoke(new java.lang.Object[] {logicalName, commandText, new java.lang.Boolean(isStoreProcedure), paraList});
if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException)_resp;
}
else {
extractAttachments(_call);
try {
return (java.lang.String) _resp;
} catch (java.lang.Exception _exception) {
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
}
}
}
}
3、下面是测试代码:
* @author Jeet
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class MyClass
{
public static void main(String[] args)
{
DBService myService=new DBServiceLocator();
try
{
String logicalName="Test";
String commandText="Select * from Customers";
boolean isStoreProcedure=false;
String para="";
System.out.println(myService.getDBServiceSoap().executeResult(logicalName,commandText,isStoreProcedure,para));
// System.out.println(myService.getDBServiceSoap().helloWorld());
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class MyClass
{
public static void main(String[] args)
{
DBService myService=new DBServiceLocator();
try
{
String logicalName="Test";
String commandText="Select * from Customers";
boolean isStoreProcedure=false;
String para="";
System.out.println(myService.getDBServiceSoap().executeResult(logicalName,commandText,isStoreProcedure,para));
// System.out.println(myService.getDBServiceSoap().helloWorld());
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
4、当返回数据量大的时候,报下列错误:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: 分析器已达到由应用程序设置的实体扩展限制"64,000"。
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace: org.xml.sax.SAXParseException: 分析器已达到由应用程序设置的实体扩展限制"64,000"。
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3370)
at org.apache.crimson.parser.Parser2.expandEntityInContent(Parser2.java:2704)
at org.apache.crimson.parser.Parser2.maybeReferenceInContent(Parser2.java:2606)
at org.apache.crimson.parser.Parser2.content(Parser2.java:2017)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at DataService.DBServiceSoapStub.executeResult(DBServiceSoapStub.java:187)
at DataService.MyClass.main(MyClass.java:33)
org.xml.sax.SAXParseException: 分析器已达到由应用程序设置的实体扩展限制"64,000"。
at org.apache.axis.AxisFault.makeFault(AxisFault.java:129)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:543)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at DataService.DBServiceSoapStub.executeResult(DBServiceSoapStub.java:187)
at DataService.MyClass.main(MyClass.java:33)
Caused by: org.xml.sax.SAXParseException: 分析器已达到由应用程序设置的实体扩展限制"64,000"。
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3370)
at org.apache.crimson.parser.Parser2.expandEntityInContent(Parser2.java:2704)
at org.apache.crimson.parser.Parser2.maybeReferenceInContent(Parser2.java:2606)
at org.apache.crimson.parser.Parser2.content(Parser2.java:2017)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
8 more
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: 分析器已达到由应用程序设置的实体扩展限制"64,000"。
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace: org.xml.sax.SAXParseException: 分析器已达到由应用程序设置的实体扩展限制"64,000"。
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3370)
at org.apache.crimson.parser.Parser2.expandEntityInContent(Parser2.java:2704)
at org.apache.crimson.parser.Parser2.maybeReferenceInContent(Parser2.java:2606)
at org.apache.crimson.parser.Parser2.content(Parser2.java:2017)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at DataService.DBServiceSoapStub.executeResult(DBServiceSoapStub.java:187)
at DataService.MyClass.main(MyClass.java:33)
org.xml.sax.SAXParseException: 分析器已达到由应用程序设置的实体扩展限制"64,000"。
at org.apache.axis.AxisFault.makeFault(AxisFault.java:129)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:543)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at DataService.DBServiceSoapStub.executeResult(DBServiceSoapStub.java:187)
at DataService.MyClass.main(MyClass.java:33)
Caused by: org.xml.sax.SAXParseException: 分析器已达到由应用程序设置的实体扩展限制"64,000"。
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3370)
at org.apache.crimson.parser.Parser2.expandEntityInContent(Parser2.java:2704)
at org.apache.crimson.parser.Parser2.maybeReferenceInContent(Parser2.java:2606)
at org.apache.crimson.parser.Parser2.content(Parser2.java:2017)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
8 more