package tw.gov.cp.sample; import java.util.Scanner; import org.apache.axis.message.MessageElement; import org.w3c.dom.Element; import tw.gov.cp.gsp2.CP2ResponseOfRSResult; import tw.gov.cp.gsp2.GSP2_RS_Service_01Soap; import tw.gov.cp.gsp2.GSP2_RS_Service_01SoapProxy; import tw.gov.cp.gsp2.GSP2_RS_Service_01SoapStub; public class AxisSample { /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); // Get token1 by user input. System.out.print("Enter token1 : "); String token1 = scanner.next(); // Get service id by user input. System.out.print("Enter service id : "); String serviceId = scanner.next(); GSP2_RS_Service_01SoapProxy proxy = new GSP2_RS_Service_01SoapProxy(); // Endpoint is defualt setted as // 'http://www.xxx.xxx.tw/GSP2WS/RSMediator01.asmx'. // For different endpoint. Use setEndpoint method or constructor to set // new WSDL. GSP2_RS_Service_01Soap soap = proxy.getGSP2_RS_Service_01Soap(); GSP2_RS_Service_01SoapStub stub = (GSP2_RS_Service_01SoapStub) soap; // Set toke1 and service id to soap header authorization stub.setAuthHeader(token1, serviceId); // Get result from server. CP2ResponseOfRSResult result = proxy.getProfileColumns(); System.out.printf("returned message : %s%n", result.getMessage()); System.out.printf("returned code : %d%n", result.getCode()); System.out.println(); if (result.getResult() != null) { MessageElement[] messages = result.getResult().getProfileCollection().get_any(); for (MessageElement msg : messages) { // key Element keyNode = ((MessageElement) msg.getFirstChild()).getAsDOM(); // value Element valueNode = ((MessageElement) msg.getLastChild()).getAsDOM(); // Print all return value System.out.printf("%s = %s%n", keyNode.getTextContent(), valueNode.getTextContent()); } } } }