|
@ -4,9 +4,10 @@ import com.yihu.ehr.dbhelper.jdbc.DBHelper;
|
|
import com.yihu.ehr.model.DataSource;
|
|
import com.yihu.ehr.model.DataSource;
|
|
import com.yihu.ehr.ws.inf.ISQLWebService;
|
|
import com.yihu.ehr.ws.inf.ISQLWebService;
|
|
import net.sf.json.JSONArray;
|
|
import net.sf.json.JSONArray;
|
|
import net.sf.json.JSONObject;
|
|
|
|
import net.sf.json.xml.XMLSerializer;
|
|
import net.sf.json.xml.XMLSerializer;
|
|
import org.apache.commons.dbcp2.BasicDataSource;
|
|
import org.apache.commons.dbcp2.BasicDataSource;
|
|
|
|
import org.apache.cxf.endpoint.Client;
|
|
|
|
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
|
|
import javax.jws.WebService;
|
|
import javax.jws.WebService;
|
|
@ -14,7 +15,7 @@ import javax.jws.WebService;
|
|
/**
|
|
/**
|
|
* Created by Administrator on 2016/5/19.
|
|
* Created by Administrator on 2016/5/19.
|
|
*/
|
|
*/
|
|
@WebService(endpointInterface = "com.yihu.ehr.ws.inf.ISQLWebService", serviceName = "testWS")
|
|
|
|
|
|
@WebService(endpointInterface = "com.yihu.ehr.ws.inf.ISQLWebService", targetNamespace = "com.yihu.ehr.ws.inf")
|
|
public class SQLWebService implements ISQLWebService {
|
|
public class SQLWebService implements ISQLWebService {
|
|
public static JdbcTemplate jdbcTemplate = null;
|
|
public static JdbcTemplate jdbcTemplate = null;
|
|
|
|
|
|
@ -74,9 +75,9 @@ public class SQLWebService implements ISQLWebService {
|
|
XMLSerializer xmlSerializer = new XMLSerializer();
|
|
XMLSerializer xmlSerializer = new XMLSerializer();
|
|
xmlSerializer.setRootName("req");
|
|
xmlSerializer.setRootName("req");
|
|
xmlSerializer.setElementName("data");
|
|
xmlSerializer.setElementName("data");
|
|
xmlSerializer.setTypeHintsEnabled(false);//设置data class="object" 没有class
|
|
|
|
// xmlSerializer.setForceTopLevelObject(false);
|
|
|
|
// xmlSerializer.setRemoveNamespacePrefixFromElements(false);
|
|
|
|
|
|
xmlSerializer.setTypeHintsEnabled(false);//设置data class="object" 没有class
|
|
|
|
// xmlSerializer.setForceTopLevelObject(false);
|
|
|
|
// xmlSerializer.setRemoveNamespacePrefixFromElements(false);
|
|
String xml = xmlSerializer.write(jo);
|
|
String xml = xmlSerializer.write(jo);
|
|
return xml;
|
|
return xml;
|
|
} catch (Exception e1) {
|
|
} catch (Exception e1) {
|
|
@ -85,4 +86,18 @@ public class SQLWebService implements ISQLWebService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
|
|
|
|
Client client = factory.createClient("http://localhost:8080/service/sql?wsdl");
|
|
|
|
|
|
|
|
try {
|
|
|
|
Object[] result = client.invoke("excuteSQL", "select * from stde_adapter_metadata"); // 按照方法的参数来提供值
|
|
|
|
if (result != null && result.length > 0) {
|
|
|
|
System.out.println(result[0]); // 通过getUsername来获取对象的username属性
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|