📄 client.java
字号:
package org.globus.examples.clients.FactoryService_Math;import org.apache.axis.message.addressing.Address;import org.apache.axis.message.addressing.EndpointReferenceType;import org.globus.examples.services.core.factory.impl.MathQNames;import org.globus.examples.stubs.MathService_instance.MathPortType;import org.globus.examples.stubs.MathService_instance.service.MathServiceAddressingLocator;import org.globus.examples.stubs.Factory.service.FactoryServiceAddressingLocator;import org.globus.examples.stubs.Factory.FactoryPortType;import org.globus.examples.stubs.Factory.CreateResource;import org.globus.examples.stubs.Factory.CreateResourceResponse;import org.oasis.wsrf.properties.GetResourcePropertyResponse;/* This client creates a new MathService instance through a FactoryService. This client * expects one parameter: the factory URI. */public class Client { public static void main(String[] args) { FactoryServiceAddressingLocator factoryLocator = new FactoryServiceAddressingLocator(); MathServiceAddressingLocator instanceLocator = new MathServiceAddressingLocator(); GetResourcePropertyResponse valueRP; String value; try { String factoryURI = args[0]; EndpointReferenceType factoryEPR, instanceEPR; FactoryPortType mathFactory; MathPortType math; // Get factory portType factoryEPR = new EndpointReferenceType(); factoryEPR.setAddress(new Address(factoryURI)); mathFactory = factoryLocator.getFactoryPortTypePort(factoryEPR); // Create resource and get endpoint reference of WS-Resource. // This resource is our "instance". CreateResourceResponse createResponse = mathFactory .createResource(new CreateResource()); instanceEPR = createResponse.getEndpointReference(); // Get instance PortType math = instanceLocator.getMathPortTypePort(instanceEPR); System.out.println("Created instance."); // Perform an addition math.add(10); // Perform another addition math.add(5); // Access value valueRP = math.getResourceProperty(MathQNames.RP_VALUE); value = valueRP.get_any()[0].getValue(); System.out.println("Current value: " + value); // Perform a subtraction math.subtract(5); // Access value valueRP = math.getResourceProperty(MathQNames.RP_VALUE); value = valueRP.get_any()[0].getValue(); System.out.println("Current value: " + value); } catch (Exception e) { e.printStackTrace(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -