📄 aleserviceclient.java
字号:
package com.logicalloy.ale.client;import java.net.MalformedURLException;import java.util.Collection;import java.util.HashMap;import javax.xml.namespace.QName;import org.codehaus.xfire.XFireRuntimeException;import org.codehaus.xfire.aegis.AegisBindingProvider;import org.codehaus.xfire.annotations.AnnotationServiceFactory;import org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations;import org.codehaus.xfire.client.XFireProxyFactory;import org.codehaus.xfire.service.Endpoint;import org.codehaus.xfire.service.Service;import org.codehaus.xfire.soap.AbstractSoapBinding;import org.codehaus.xfire.transport.TransportManager;import org.codehaus.xfire.xmlbeans.XmlBeansTypeRegistry;public class ALEServiceClient { private static XFireProxyFactory proxyFactory = new XFireProxyFactory(); private HashMap endpoints = new HashMap(); private Service service0; public ALEServiceClient() { create0(); Endpoint ALEServicePortEP = service0 .addEndpoint(new QName("urn:epcglobal:ale:wsdl:1", "ALEServicePort"), new QName("urn:epcglobal:ale:wsdl:1", "ALEServiceBinding"), "http://localhost:8080/api/services/ALEService"); endpoints.put(new QName("urn:epcglobal:ale:wsdl:1", "ALEServicePort"), ALEServicePortEP); Endpoint ALEServicePortTypeLocalEndpointEP = service0 .addEndpoint(new QName("urn:epcglobal:ale:wsdl:1", "ALEServicePortTypeLocalEndpoint"), new QName("urn:epcglobal:ale:wsdl:1", "ALEServicePortTypeLocalBinding"), "xfire.local://ALEService"); endpoints.put(new QName("urn:epcglobal:ale:wsdl:1", "ALEServicePortTypeLocalEndpoint"), ALEServicePortTypeLocalEndpointEP); } public Object getEndpoint(Endpoint endpoint) { try { return proxyFactory.create((endpoint).getBinding(), (endpoint).getUrl()); } catch (MalformedURLException e) { throw new XFireRuntimeException("Invalid URL", e); } } public Object getEndpoint(QName name) { Endpoint endpoint = ((Endpoint) endpoints.get((name))); if ((endpoint) == null) { throw new IllegalStateException("No such endpoint!"); } return getEndpoint((endpoint)); } public Collection getEndpoints() { return endpoints.values(); } private void create0() { TransportManager tm = (org.codehaus.xfire.XFireFactory.newInstance().getXFire().getTransportManager()); HashMap props = new HashMap(); props.put("annotations.allow.interface", true); AnnotationServiceFactory asf = new AnnotationServiceFactory(new Jsr181WebAnnotations(), tm, new AegisBindingProvider(new XmlBeansTypeRegistry())); asf.setBindingCreationEnabled(false); service0 = asf.create((com.logicalloy.ale.client.ALEServicePortType.class), props); { AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0, new QName("urn:epcglobal:ale:wsdl:1", "ALEServiceBinding"), "http://schemas.xmlsoap.org/soap/http"); } { AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0, new QName("urn:epcglobal:ale:wsdl:1", "ALEServicePortTypeLocalBinding"), "urn:xfire:transport:local"); } } public ALEServicePortType getALEServicePort() { return ((ALEServicePortType)(this).getEndpoint(new QName("urn:epcglobal:ale:wsdl:1", "ALEServicePort"))); } public ALEServicePortType getALEServicePort(String url) { ALEServicePortType var = getALEServicePort(); org.codehaus.xfire.client.Client.getInstance(var).setUrl(url); return var; } public ALEServicePortType getALEServicePortTypeLocalEndpoint() { return ((ALEServicePortType)(this).getEndpoint(new QName("urn:epcglobal:ale:wsdl:1", "ALEServicePortTypeLocalEndpoint"))); } public ALEServicePortType getALEServicePortTypeLocalEndpoint(String url) { ALEServicePortType var = getALEServicePortTypeLocalEndpoint(); org.codehaus.xfire.client.Client.getInstance(var).setUrl(url); return var; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -