Fixed some bugs
This commit is contained in:
parent
73be002969
commit
19a0e92d88
4 changed files with 126 additions and 62 deletions
|
|
@ -18,24 +18,41 @@ public class MySQLConnection {
|
||||||
* @param user is the user name
|
* @param user is the user name
|
||||||
* @param password is the password
|
* @param password is the password
|
||||||
*/
|
*/
|
||||||
public MySQLConnection(String url,String db,String user, String password) throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException{
|
public MySQLConnection(String url, String db, String user, String password)
|
||||||
|
throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException{
|
||||||
Class.forName ("com.mysql.jdbc.Driver").newInstance();
|
Class.forName ("com.mysql.jdbc.Driver").newInstance();
|
||||||
conn = DriverManager.getConnection ("jdbc:mysql://"+url+"/"+db, user, password);
|
conn = DriverManager.getConnection ("jdbc:mysql://"+url+"/"+db, user, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs a query and returns the result.<br>
|
* Runs a query and returns the result.<br>
|
||||||
* <b>NOTE:</b> Don't forget to close the ResultSet and the Statement or it can lead to memory leak tex: rows.getStatement().close();
|
* <b>NOTE:</b> Don't forget to close the ResultSet and the Statement or it
|
||||||
|
* can lead to memory leak: rows.getStatement().close();
|
||||||
*
|
*
|
||||||
* @param sql is the query to execute
|
* @param sql is the query to execute
|
||||||
* @return the data that the DB returned
|
* @return the data that the DB returned
|
||||||
*/
|
*/
|
||||||
public synchronized ResultSet returnQuery(String sql) throws SQLException{
|
public synchronized ResultSet query(String sql) throws SQLException{
|
||||||
Statement s = conn.createStatement ();
|
Statement s = conn.createStatement ();
|
||||||
s.executeQuery (sql);
|
s.executeQuery(sql);
|
||||||
return s.getResultSet();
|
return s.getResultSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the first cell of the first row of the query
|
||||||
|
*
|
||||||
|
* @param sql is the SQL query to run, preferably with the LIMIT 1 at the end
|
||||||
|
* @return A SQL row if it exists or else null
|
||||||
|
*/
|
||||||
|
public synchronized String simpleQuery(String sql) throws SQLException{
|
||||||
|
Statement s = conn.createStatement ();
|
||||||
|
s.executeQuery(sql);
|
||||||
|
ResultSet result = s.getResultSet();
|
||||||
|
if(result.next())
|
||||||
|
return result.getString(0);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs a query in the MySQL server and returns effected rows
|
* Runs a query in the MySQL server and returns effected rows
|
||||||
*
|
*
|
||||||
|
|
@ -52,6 +69,7 @@ public class MySQLConnection {
|
||||||
/**
|
/**
|
||||||
* Runs a Prepared Statement.<br>
|
* Runs a Prepared Statement.<br>
|
||||||
* <b>NOTE:</b> Don't forget to close the PreparedStatement or it can lead to memory leak
|
* <b>NOTE:</b> Don't forget to close the PreparedStatement or it can lead to memory leak
|
||||||
|
*
|
||||||
* @param sql is the SQL query to run
|
* @param sql is the SQL query to run
|
||||||
* @return The PreparedStatement
|
* @return The PreparedStatement
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public class MySQLQueue<E> implements Queue<E>{
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public synchronized E peek() {
|
public synchronized E peek() {
|
||||||
try {
|
try {
|
||||||
ResultSet rs = db.returnQuery("SELECT * FROM "+table+" LIMIT 1");
|
ResultSet rs = db.query("SELECT * FROM "+table+" LIMIT 1");
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
return (E) Converter.toObject(rs.getBytes("data"));
|
return (E) Converter.toObject(rs.getBytes("data"));
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +77,7 @@ public class MySQLQueue<E> implements Queue<E>{
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public synchronized E poll() {
|
public synchronized E poll() {
|
||||||
try {
|
try {
|
||||||
ResultSet rs = db.returnQuery("SELECT * FROM "+table+" LIMIT 1");
|
ResultSet rs = db.query("SELECT * FROM "+table+" LIMIT 1");
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
db.updateQuery("DELETE FROM "+table+" WHERE id="+rs.getInt("id")+" LIMIT 1");
|
db.updateQuery("DELETE FROM "+table+" WHERE id="+rs.getInt("id")+" LIMIT 1");
|
||||||
return (E) Converter.toObject(rs.getBytes("data"));
|
return (E) Converter.toObject(rs.getBytes("data"));
|
||||||
|
|
@ -108,7 +108,7 @@ public class MySQLQueue<E> implements Queue<E>{
|
||||||
|
|
||||||
public boolean contains(Object arg0) {
|
public boolean contains(Object arg0) {
|
||||||
try {
|
try {
|
||||||
ResultSet rs = db.returnQuery("SELECT data FROM "+table+" WHERE data='"+Converter.toBytes(arg0)+"' LIMIT 1");
|
ResultSet rs = db.query("SELECT data FROM "+table+" WHERE data='"+Converter.toBytes(arg0)+"' LIMIT 1");
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -135,7 +135,7 @@ public class MySQLQueue<E> implements Queue<E>{
|
||||||
|
|
||||||
public synchronized boolean remove(Object arg0) {
|
public synchronized boolean remove(Object arg0) {
|
||||||
try {
|
try {
|
||||||
ResultSet rs = db.returnQuery("DELETE FROM "+table+" WHERE data='"+Converter.toBytes(arg0)+"' LIMIT 1");
|
ResultSet rs = db.query("DELETE FROM "+table+" WHERE data='"+Converter.toBytes(arg0)+"' LIMIT 1");
|
||||||
rs.getStatement().close();
|
rs.getStatement().close();
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -156,7 +156,7 @@ public class MySQLQueue<E> implements Queue<E>{
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
try {
|
try {
|
||||||
ResultSet rs = db.returnQuery("SELECT count(*) FROM "+table);
|
ResultSet rs = db.query("SELECT count(*) FROM "+table);
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
return rs.getInt(1);
|
return rs.getInt(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -244,13 +244,13 @@ public class HttpServer extends Thread{
|
||||||
tmpb.append((char)in.read());
|
tmpb.append((char)in.read());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(client_info.get("Content-Type").equals("application/x-www-form-urlencoded")){
|
if(client_info.get("Content-Type").contains("application/x-www-form-urlencoded")){
|
||||||
// get the variables
|
// get the variables
|
||||||
parseVariables(tmpb.toString(), request);
|
parseVariables(tmpb.toString(), request);
|
||||||
}
|
}
|
||||||
else if(client_info.get("Content-Type").equals("application/soap+xml") ||
|
else if(client_info.get("Content-Type").contains("application/soap+xml") ||
|
||||||
client_info.get("Content-Type").equals("text/xml") ||
|
client_info.get("Content-Type").contains("text/xml") ||
|
||||||
client_info.get("Content-Type").equals("text/plain")){
|
client_info.get("Content-Type").contains("text/plain")){
|
||||||
// save the variables
|
// save the variables
|
||||||
request.put("" , tmpb.toString());
|
request.put("" , tmpb.toString());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,6 @@ import javax.wsdl.factory.WSDLFactory;
|
||||||
import javax.wsdl.xml.WSDLWriter;
|
import javax.wsdl.xml.WSDLWriter;
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import zutil.network.http.HttpPage;
|
|
||||||
import zutil.network.http.HttpPrintStream;
|
|
||||||
import zutil.network.http.soap.SOAPInterface.WSDLDocumentation;
|
|
||||||
import zutil.network.http.soap.SOAPInterface.WSDLParamDocumentation;
|
|
||||||
import zutil.network.http.soap.SOAPObject.SOAPFieldName;
|
|
||||||
import zutil.MultiPrintStream;
|
|
||||||
|
|
||||||
import org.dom4j.Document;
|
import org.dom4j.Document;
|
||||||
import org.dom4j.DocumentException;
|
import org.dom4j.DocumentException;
|
||||||
import org.dom4j.DocumentHelper;
|
import org.dom4j.DocumentHelper;
|
||||||
|
|
@ -53,6 +46,13 @@ import org.dom4j.io.OutputFormat;
|
||||||
import org.dom4j.io.XMLWriter;
|
import org.dom4j.io.XMLWriter;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import zutil.MultiPrintStream;
|
||||||
|
import zutil.network.http.HttpPage;
|
||||||
|
import zutil.network.http.HttpPrintStream;
|
||||||
|
import zutil.network.http.soap.SOAPInterface.WSDLDocumentation;
|
||||||
|
import zutil.network.http.soap.SOAPInterface.WSDLParamDocumentation;
|
||||||
|
import zutil.network.http.soap.SOAPObject.SOAPFieldName;
|
||||||
|
|
||||||
import com.ibm.wsdl.extensions.PopulatedExtensionRegistry;
|
import com.ibm.wsdl.extensions.PopulatedExtensionRegistry;
|
||||||
import com.ibm.wsdl.extensions.soap.SOAPConstants;
|
import com.ibm.wsdl.extensions.soap.SOAPConstants;
|
||||||
import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
|
import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
|
||||||
|
|
@ -89,16 +89,16 @@ import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
|
||||||
*/
|
*/
|
||||||
public class SOAPHttpPage implements HttpPage{
|
public class SOAPHttpPage implements HttpPage{
|
||||||
// valid methods for this soap page
|
// valid methods for this soap page
|
||||||
private HashMap<String, MethodChasch> methods;
|
private HashMap<String, MethodCache> methods;
|
||||||
// contains an method and the names for the parameters
|
// contains an method and the names for the parameters
|
||||||
private class MethodChasch{
|
private class MethodCache{
|
||||||
String[] paramName;
|
String[] paramName;
|
||||||
boolean[] paramOptional;
|
boolean[] paramOptional;
|
||||||
String returnName;
|
String returnName;
|
||||||
Method method;
|
Method method;
|
||||||
boolean header;
|
boolean header;
|
||||||
|
|
||||||
MethodChasch(Method m){
|
MethodCache(Method m){
|
||||||
method = m;
|
method = m;
|
||||||
paramName = new String[method.getParameterTypes().length];
|
paramName = new String[method.getParameterTypes().length];
|
||||||
paramOptional = new boolean[method.getParameterTypes().length];
|
paramOptional = new boolean[method.getParameterTypes().length];
|
||||||
|
|
@ -122,13 +122,13 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.interf = interf;
|
this.interf = interf;
|
||||||
this.session_enabled = false;
|
this.session_enabled = false;
|
||||||
methods = new HashMap<String, MethodChasch>();
|
methods = new HashMap<String, MethodCache>();
|
||||||
|
|
||||||
for(Method m : interf.getClass().getDeclaredMethods()){
|
for(Method m : interf.getClass().getDeclaredMethods()){
|
||||||
// check for public methods
|
// check for public methods
|
||||||
if((m.getModifiers() & Modifier.PUBLIC) > 0 &&
|
if((m.getModifiers() & Modifier.PUBLIC) > 0 &&
|
||||||
!m.isAnnotationPresent(SOAPInterface.SOAPDisabled.class)){
|
!m.isAnnotationPresent(SOAPInterface.SOAPDisabled.class)){
|
||||||
MethodChasch chasch = new MethodChasch(m);
|
MethodCache chasch = new MethodCache(m);
|
||||||
StringBuffer tmp = new StringBuffer(m.getName()+"(");
|
StringBuffer tmp = new StringBuffer(m.getName()+"(");
|
||||||
|
|
||||||
// Get the parameter names
|
// Get the parameter names
|
||||||
|
|
@ -218,11 +218,21 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
if(session_enabled) session.put("SOAPInterface", obj);
|
if(session_enabled) session.put("SOAPInterface", obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Document document = soapResponse( request.get(""), obj);
|
Document document = soapResponse( request.get(""), obj);
|
||||||
|
|
||||||
OutputFormat format = OutputFormat.createPrettyPrint();
|
OutputFormat format = OutputFormat.createPrettyPrint();
|
||||||
XMLWriter writer = new XMLWriter( out, format );
|
XMLWriter writer = new XMLWriter( out, format );
|
||||||
writer.write( document );
|
writer.write( document );
|
||||||
|
|
||||||
|
/*
|
||||||
|
// DEBUG
|
||||||
|
System.out.println("Request");
|
||||||
|
System.out.println(request);
|
||||||
|
System.out.println("Response");
|
||||||
|
writer = new XMLWriter( System.out, format );
|
||||||
|
writer.write( document );
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace(MultiPrintStream.out);
|
e.printStackTrace(MultiPrintStream.out);
|
||||||
|
|
@ -238,24 +248,25 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
try {
|
try {
|
||||||
return soapResponse(xml, interf.getClass().newInstance());
|
return soapResponse(xml, interf.getClass().newInstance());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace(MultiPrintStream.out);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Document soapResponse(String xml, SOAPInterface obj){
|
protected Document soapResponse(String xml, SOAPInterface obj){
|
||||||
|
Document document = DocumentHelper.createDocument();
|
||||||
|
Element envelope = document.addElement("soap:Envelope");
|
||||||
try {
|
try {
|
||||||
Document document = DocumentHelper.createDocument();
|
envelope.add(new Namespace("soap", "http://schemas.xmlsoap.org/soap/envelope/"));
|
||||||
Element envelope = document.addElement("soap:Envelope");
|
envelope.addAttribute("soap:encodingStyle", "http://schemas.xmlsoap.org/soap/envelope/");
|
||||||
envelope.add(new Namespace("soap", "http://www.w3.org/2001/12/soap-envelope"));
|
|
||||||
envelope.addAttribute("soap:encodingStyle", "http://www.w3.org/2001/12/soap-encoding");
|
|
||||||
|
|
||||||
Element header = envelope.addElement( "soap:Header" );
|
|
||||||
Element body = envelope.addElement( "soap:Body" );
|
Element body = envelope.addElement( "soap:Body" );
|
||||||
try{
|
try{
|
||||||
Element request = getXMLRoot(xml);
|
Element request = getXMLRoot(xml);
|
||||||
|
if(request == null) return document;
|
||||||
// Header
|
// Header
|
||||||
if( request.element("Header") != null){
|
if( request.element("Header") != null){
|
||||||
|
Element header = envelope.addElement( "soap:Header" );
|
||||||
prepareInvoke( obj, request.element("Header"), header );
|
prepareInvoke( obj, request.element("Header"), header );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,13 +289,11 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
fault.addElement("faultstring").setText( ""+e.getMessage() );
|
fault.addElement("faultstring").setText( ""+e.getMessage() );
|
||||||
e.printStackTrace(MultiPrintStream.out);
|
e.printStackTrace(MultiPrintStream.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
return document;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace(MultiPrintStream.out);
|
e.printStackTrace(MultiPrintStream.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -301,7 +310,7 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
while( it.hasNext() ){
|
while( it.hasNext() ){
|
||||||
Element e = it.next();
|
Element e = it.next();
|
||||||
if(methods.containsKey(e.getQName().getName())){
|
if(methods.containsKey(e.getQName().getName())){
|
||||||
MethodChasch m = methods.get(e.getQName().getName());
|
MethodCache m = methods.get(e.getQName().getName());
|
||||||
Object[] params = new Object[m.paramName.length];
|
Object[] params = new Object[m.paramName.length];
|
||||||
|
|
||||||
// Get the param values
|
// Get the param values
|
||||||
|
|
@ -318,7 +327,7 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
// generate response xml
|
// generate response xml
|
||||||
if(m.method.getReturnType() != void.class){
|
if(m.method.getReturnType() != void.class){
|
||||||
Element response = responseRoot.addElement(m.method.getName()+"Response");
|
Element response = responseRoot.addElement(m.method.getName()+"Response");
|
||||||
createReturnXML(response, ret, m.returnName, m);
|
generateReturnXML(response, ret, m.returnName, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -337,7 +346,7 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
* @param ename is the name of the parent Element
|
* @param ename is the name of the parent Element
|
||||||
* @param m is the method that returned the ret
|
* @param m is the method that returned the ret
|
||||||
*/
|
*/
|
||||||
private void createReturnXML(Element root, Object ret, String ename, MethodChasch m) throws IllegalArgumentException, IllegalAccessException{
|
private void generateReturnXML(Element root, Object ret, String ename, MethodCache m) throws IllegalArgumentException, IllegalAccessException{
|
||||||
if(ret == null) return;
|
if(ret == null) return;
|
||||||
if(byte[].class.isAssignableFrom(ret.getClass())){
|
if(byte[].class.isAssignableFrom(ret.getClass())){
|
||||||
Element valueE = root.addElement( ename );
|
Element valueE = root.addElement( ename );
|
||||||
|
|
@ -355,7 +364,7 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
array.addAttribute("type", "soap:Array");
|
array.addAttribute("type", "soap:Array");
|
||||||
array.addAttribute("soap:arrayType", arrayType);
|
array.addAttribute("soap:arrayType", arrayType);
|
||||||
for(int i=0; i<Array.getLength(ret) ;i++){
|
for(int i=0; i<Array.getLength(ret) ;i++){
|
||||||
createReturnXML(array, Array.get(ret, i), "element", m);
|
generateReturnXML(array, Array.get(ret, i), "element", m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -369,7 +378,7 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
String name;
|
String name;
|
||||||
if(tmp != null) name = tmp.value();
|
if(tmp != null) name = tmp.value();
|
||||||
else name = "field"+i;
|
else name = "field"+i;
|
||||||
createReturnXML(objectE, fields[i].get(ret), name, m);
|
generateReturnXML(objectE, fields[i].get(ret), name, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -485,12 +494,21 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
|
|
||||||
Message exception = wsdl.createMessage();
|
Message exception = wsdl.createMessage();
|
||||||
exception.setQName(new QName(tns, "exception"));
|
exception.setQName(new QName(tns, "exception"));
|
||||||
exception.setUndefined(false);
|
exception.setUndefined(true);
|
||||||
Part epart = wsdl.createPart();
|
Part epart = wsdl.createPart();
|
||||||
epart.setName("message");
|
epart.setName("message");
|
||||||
epart.setTypeName(new QName(xsd, "string"));
|
epart.setTypeName(new QName(xsd, "string"));
|
||||||
exception.addPart(epart);
|
exception.addPart(epart);
|
||||||
wsdl.addMessage(exception);
|
wsdl.addMessage(exception);
|
||||||
|
|
||||||
|
Message empty = wsdl.createMessage();
|
||||||
|
empty.setQName(new QName(tns, "empty"));
|
||||||
|
empty.setUndefined(false);
|
||||||
|
epart = wsdl.createPart();
|
||||||
|
epart.setName("empty");
|
||||||
|
epart.setTypeName(new QName(td, "empty"));
|
||||||
|
empty.addPart(epart);
|
||||||
|
wsdl.addMessage(empty);
|
||||||
|
|
||||||
// Types import
|
// Types import
|
||||||
Import imp = wsdl.createImport();
|
Import imp = wsdl.createImport();
|
||||||
|
|
@ -502,7 +520,7 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
PortType portType = wsdl.createPortType();
|
PortType portType = wsdl.createPortType();
|
||||||
portType.setQName(new QName(tns, portTypeName));
|
portType.setQName(new QName(tns, portTypeName));
|
||||||
portType.setUndefined(false);
|
portType.setUndefined(false);
|
||||||
for(MethodChasch m : methods.values()){
|
for(MethodCache m : methods.values()){
|
||||||
Operation operation = wsdl.createOperation();
|
Operation operation = wsdl.createOperation();
|
||||||
//********* Request Messages
|
//********* Request Messages
|
||||||
if(m.paramName.length > 0){
|
if(m.paramName.length > 0){
|
||||||
|
|
@ -535,6 +553,11 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
input.setMessage(msgIn);
|
input.setMessage(msgIn);
|
||||||
operation.setInput(input);
|
operation.setInput(input);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
Input input = wsdl.createInput();
|
||||||
|
input.setMessage(empty);
|
||||||
|
operation.setInput(input);
|
||||||
|
}
|
||||||
//********** Response Message
|
//********** Response Message
|
||||||
if(!m.method.getReturnType().equals( void.class )){
|
if(!m.method.getReturnType().equals( void.class )){
|
||||||
Message msgOut = wsdl.createMessage();
|
Message msgOut = wsdl.createMessage();
|
||||||
|
|
@ -611,30 +634,30 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
|
soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
|
||||||
binding.addExtensibilityElement(soapBinding);
|
binding.addExtensibilityElement(soapBinding);
|
||||||
|
|
||||||
for(MethodChasch m : methods.values()){
|
for(MethodCache m : methods.values()){
|
||||||
BindingOperation operation = wsdl.createBindingOperation();
|
BindingOperation operation = wsdl.createBindingOperation();
|
||||||
operation.setName(m.method.getName());
|
operation.setName(m.method.getName());
|
||||||
|
|
||||||
SOAPOperation soapOperation = (SOAPOperation)extReg.createExtension(BindingOperation.class, SOAPConstants.Q_ELEM_SOAP_OPERATION);
|
SOAPOperation soapOperation = (SOAPOperation)extReg.createExtension(BindingOperation.class, SOAPConstants.Q_ELEM_SOAP_OPERATION);
|
||||||
soapOperation.setSoapActionURI("");
|
soapOperation.setSoapActionURI(url+""+m.method.getName());
|
||||||
operation.addExtensibilityElement(soapOperation);
|
operation.addExtensibilityElement(soapOperation);
|
||||||
|
|
||||||
// input
|
// input
|
||||||
if(m.paramName.length > 0){
|
BindingInput input = wsdl.createBindingInput();
|
||||||
BindingInput input = wsdl.createBindingInput();
|
// Header
|
||||||
// Header
|
if(m.header){
|
||||||
if(m.header){
|
SOAPHeader soapHeader = (SOAPHeader)extReg.createExtension(BindingInput.class, SOAPConstants.Q_ELEM_SOAP_HEADER);
|
||||||
SOAPHeader soapHeader = (SOAPHeader)extReg.createExtension(BindingInput.class, SOAPConstants.Q_ELEM_SOAP_HEADER);
|
soapHeader.setUse("literal");
|
||||||
soapHeader.setUse("literal");
|
soapHeader.setNamespaceURI(url+""+m.method.getName());
|
||||||
input.addExtensibilityElement(soapHeader);
|
input.addExtensibilityElement(soapHeader);
|
||||||
}// Body
|
}// Body
|
||||||
else{
|
else{
|
||||||
SOAPBody soapBody = (SOAPBody)extReg.createExtension(BindingInput.class, SOAPConstants.Q_ELEM_SOAP_BODY);
|
SOAPBody soapBody = (SOAPBody)extReg.createExtension(BindingInput.class, SOAPConstants.Q_ELEM_SOAP_BODY);
|
||||||
soapBody.setUse("literal");
|
soapBody.setUse("literal");
|
||||||
input.addExtensibilityElement(soapBody);
|
soapBody.setNamespaceURI(url+""+m.method.getName());
|
||||||
}
|
input.addExtensibilityElement(soapBody);
|
||||||
operation.setBindingInput(input);
|
|
||||||
}
|
}
|
||||||
|
operation.setBindingInput(input);
|
||||||
|
|
||||||
// output
|
// output
|
||||||
if(!m.method.getReturnType().equals( void.class )){
|
if(!m.method.getReturnType().equals( void.class )){
|
||||||
|
|
@ -643,11 +666,13 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
if(m.header){
|
if(m.header){
|
||||||
SOAPHeader soapHeader = (SOAPHeader)extReg.createExtension(BindingInput.class, SOAPConstants.Q_ELEM_SOAP_HEADER);
|
SOAPHeader soapHeader = (SOAPHeader)extReg.createExtension(BindingInput.class, SOAPConstants.Q_ELEM_SOAP_HEADER);
|
||||||
soapHeader.setUse("literal");
|
soapHeader.setUse("literal");
|
||||||
|
soapHeader.setNamespaceURI(url+""+m.method.getName());
|
||||||
output.addExtensibilityElement(soapHeader);
|
output.addExtensibilityElement(soapHeader);
|
||||||
}// Body
|
}// Body
|
||||||
else{
|
else{
|
||||||
SOAPBody soapBody = (SOAPBody)extReg.createExtension(BindingInput.class, SOAPConstants.Q_ELEM_SOAP_BODY);
|
SOAPBody soapBody = (SOAPBody)extReg.createExtension(BindingInput.class, SOAPConstants.Q_ELEM_SOAP_BODY);
|
||||||
soapBody.setUse("literal");
|
soapBody.setUse("literal");
|
||||||
|
soapBody.setNamespaceURI(url+""+m.method.getName());
|
||||||
output.addExtensibilityElement(soapBody);
|
output.addExtensibilityElement(soapBody);
|
||||||
}
|
}
|
||||||
operation.setBindingOutput(output);
|
operation.setBindingOutput(output);
|
||||||
|
|
@ -683,12 +708,19 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
wsdlType = DocumentHelper.createDocument();
|
wsdlType = DocumentHelper.createDocument();
|
||||||
Element definitions = wsdlType.addElement( "wsdl:definitions" );
|
Element definitions = wsdlType.addElement( "wsdl:definitions" );
|
||||||
definitions.addAttribute("targetNamespace", url+"?type");
|
definitions.addAttribute("targetNamespace", url+"?type");
|
||||||
|
definitions.addNamespace("tns", url+"?type");
|
||||||
definitions.addNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
|
definitions.addNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
|
||||||
definitions.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
|
definitions.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
|
||||||
definitions.addNamespace("SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/");
|
definitions.addNamespace("SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/");
|
||||||
|
|
||||||
Element typeE = definitions.addElement("wsdl:types");
|
Element typeE = definitions.addElement("wsdl:types");
|
||||||
Element schema = typeE.addElement("xsd:schema");
|
Element schema = typeE.addElement("xsd:schema");
|
||||||
|
schema.addAttribute("targetNamespace", url+"?type");
|
||||||
|
|
||||||
|
// empty type
|
||||||
|
Element empty = schema.addElement("xsd:complexType");
|
||||||
|
empty.addAttribute("name", "empty");
|
||||||
|
empty.addElement("xsd:sequence");
|
||||||
|
|
||||||
for(int n=0; n<types.size() ;n++){
|
for(int n=0; n<types.size() ;n++){
|
||||||
Class<?> c = types.get(n);
|
Class<?> c = types.get(n);
|
||||||
|
|
@ -699,6 +731,8 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
Element type = schema.addElement("xsd:complexType");
|
Element type = schema.addElement("xsd:complexType");
|
||||||
type.addAttribute("name",
|
type.addAttribute("name",
|
||||||
"ArrayOf"+getClassSOAPName(c).replaceAll("[\\[\\]]", ""));
|
"ArrayOf"+getClassSOAPName(c).replaceAll("[\\[\\]]", ""));
|
||||||
|
|
||||||
|
/*// .Net can't handle this code
|
||||||
Element complexContent = type.addElement("complexContent");
|
Element complexContent = type.addElement("complexContent");
|
||||||
|
|
||||||
Element restriction = complexContent.addElement("restriction");
|
Element restriction = complexContent.addElement("restriction");
|
||||||
|
|
@ -707,6 +741,19 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
Element attribute = restriction.addElement("attribute");
|
Element attribute = restriction.addElement("attribute");
|
||||||
attribute.addAttribute("ref", "SOAP-ENC:arrayType");
|
attribute.addAttribute("ref", "SOAP-ENC:arrayType");
|
||||||
attribute.addAttribute("wsdl:arrayType", "tns:"+getClassSOAPName(c));
|
attribute.addAttribute("wsdl:arrayType", "tns:"+getClassSOAPName(c));
|
||||||
|
*/
|
||||||
|
|
||||||
|
Element sequence = type.addElement("xsd:sequence");
|
||||||
|
|
||||||
|
Element element = sequence.addElement("xsd:element");
|
||||||
|
element.addAttribute("minOccurs", "0");
|
||||||
|
element.addAttribute("maxOccurs", "unbounded");
|
||||||
|
element.addAttribute("name", "element");
|
||||||
|
element.addAttribute("nillable", "true");
|
||||||
|
if(SOAPObject.class.isAssignableFrom(ctmp))
|
||||||
|
element.addAttribute("type", "tns:"+getClassSOAPName(c).replace("[]", ""));
|
||||||
|
else
|
||||||
|
element.addAttribute("type", "xsd:"+getClassSOAPName(c).replace("[]", ""));
|
||||||
|
|
||||||
if(!types.contains(ctmp))
|
if(!types.contains(ctmp))
|
||||||
types.add(ctmp);
|
types.add(ctmp);
|
||||||
|
|
@ -752,5 +799,4 @@ public class SOAPHttpPage implements HttpPage{
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue