本文整理汇总了Java中javax.xml.ws.Dispatch类的典型用法代码示例。如果您正苦于以下问题:Java Dispatch类的具体用法?Java Dispatch怎么用?Java Dispatch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Dispatch类属于javax.xml.ws包,在下文中一共展示了Dispatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDispatch
import javax.xml.ws.Dispatch; //导入依赖的package包/类
/**
* Creates a new {@link Dispatch} stub that connects to the given pipe.
*
* @param portName
* see {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param owner
* see <a href="#param">common parameters</a>
* @param binding
* see <a href="#param">common parameters</a>
* @param clazz
* Type of the {@link Dispatch} to be created.
* See {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param mode
* The mode of the dispatch.
* See {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param next
* see <a href="#param">common parameters</a>
* @param epr
* see <a href="#param">common parameters</a>
* TODO: are these parameters making sense?
*/
@SuppressWarnings("unchecked")
public static <T> Dispatch<T> createDispatch(QName portName,
WSService owner,
WSBinding binding,
Class<T> clazz, Service.Mode mode, Tube next,
@Nullable WSEndpointReference epr) {
if (clazz == SOAPMessage.class) {
return (Dispatch<T>) createSAAJDispatch(portName, owner, binding, mode, next, epr);
} else if (clazz == Source.class) {
return (Dispatch<T>) createSourceDispatch(portName, owner, binding, mode, next, epr);
} else if (clazz == DataSource.class) {
return (Dispatch<T>) createDataSourceDispatch(portName, owner, binding, mode, next, epr);
} else if (clazz == Message.class) {
if(mode==Mode.MESSAGE)
return (Dispatch<T>) createMessageDispatch(portName, owner, binding, next, epr);
else
throw new WebServiceException(mode+" not supported with Dispatch<Message>");
} else if (clazz == Packet.class) {
return (Dispatch<T>) createPacketDispatch(portName, owner, binding, next, epr);
} else
throw new WebServiceException("Unknown class type " + clazz.getName());
}
示例2: createDispatch
import javax.xml.ws.Dispatch; //导入依赖的package包/类
public <T> Dispatch<T> createDispatch(QName portName, WSEndpointReference wsepr, Class<T> aClass, Service.Mode mode, WebServiceFeatureList features) {
PortInfo port = safeGetPort(portName);
ComponentFeature cf = features.get(ComponentFeature.class);
if (cf != null && !Target.STUB.equals(cf.getTarget())) {
throw new IllegalArgumentException();
}
ComponentsFeature csf = features.get(ComponentsFeature.class);
if (csf != null) {
for (ComponentFeature cfi : csf.getComponentFeatures()) {
if (!Target.STUB.equals(cfi.getTarget()))
throw new IllegalArgumentException();
}
}
features.addAll(this.features);
BindingImpl binding = port.createBinding(features, null, null);
binding.setMode(mode);
Dispatch<T> dispatch = Stubs.createDispatch(port, this, binding, aClass, mode, wsepr);
serviceInterceptor.postCreateDispatch((WSBindingProvider) dispatch);
return dispatch;
}
示例3: getDispatch
import javax.xml.ws.Dispatch; //导入依赖的package包/类
private Dispatch<Source> getDispatch() {
Service helloService = Service.create(getClass().getResource("/META-INF/wsdl/GreetingService-1.0/GreetingService.wsdl"),
new QName("http://hello.respiro.kantega.org/ws/greet-1.0", "GreetingService"));
Dispatch<Source> helloPort = helloService.createDispatch(new QName("http://hello.respiro.kantega.org/ws/greet-1.0", "GreetingPort"),
Source.class, Service.Mode.PAYLOAD);
BindingProvider prov = (BindingProvider)helloPort;
Map<String,Object> rc = prov.getRequestContext();
rc.put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
rc.put(BindingProvider.SOAPACTION_URI_PROPERTY, "greet");
rc.put(BindingProvider.USERNAME_PROPERTY, "joe");
rc.put(BindingProvider.PASSWORD_PROPERTY, "joe");
rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + Utils.getReststopPort() + "/ws/dummy/greeting-1.0");
return helloPort;
}
示例4: testConfigurationChangeOnDispatch
import javax.xml.ws.Dispatch; //导入依赖的package包/类
public boolean testConfigurationChangeOnDispatch() throws Exception
{
Service service = Service.create(new URL(address + "?wsdl"), serviceName);
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
org.apache.cxf.endpoint.Endpoint ep = ((DispatchImpl<SOAPMessage>)dispatch).getClient().getEndpoint();
assert(ep.get("propA") == null);
assert(ep.get("propB") == null);
ep.put("propZ", "valueZ");
ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
configurer.setConfigProperties(dispatch, "META-INF/jaxws-client-config.xml", "Custom Client Config");
if (!ep.get("propA").equals("fileValueA") || !ep.get("propB").equals("fileValueB") || !ep.get("propZ").equals("valueZ")) {
return false;
}
configurer.setConfigProperties(dispatch, "META-INF/jaxws-client-config.xml", "Another Client Config");
return (ep.get("propA") == null && ep.get("propB") == null && ep.get("propC").equals("fileValueC") && ep.get("propZ").equals("valueZ"));
}
示例5: testDefaultClientConfigurationOnDispatch
import javax.xml.ws.Dispatch; //导入依赖的package包/类
public boolean testDefaultClientConfigurationOnDispatch() throws Exception
{
final URL wsdlURL = new URL(address + "?wsdl");
final ClientConfig defaultClientConfig = TestUtils.getAndVerifyDefaultClientConfiguration();
// -- modify default conf --
try
{
final Map<String, String> props = new HashMap<String, String>();
props.put("propA", "valueA");
TestUtils.registerClientConfigAndReload(new ClientConfig(defaultClientConfig.getConfigName(), null, null, props, null));
// --
Service service = Service.create(wsdlURL, serviceName);
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
return (((DispatchImpl<SOAPMessage>)dispatch).getClient().getEndpoint().get("propA").equals("valueA"));
}
finally
{
// -- restore default conf --
TestUtils.registerClientConfigAndReload(defaultClientConfig);
// --
}
}
示例6: testCustomClientConfigurationOnDispatch
import javax.xml.ws.Dispatch; //导入依赖的package包/类
public boolean testCustomClientConfigurationOnDispatch() throws Exception
{
final URL wsdlURL = new URL(address + "?wsdl");
final String testConfigName = "MyTestConfig";
try
{
//-- add test client configuration
TestUtils.addTestCaseClientConfiguration(testConfigName);
// --
Service service = Service.create(wsdlURL, serviceName);
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
org.apache.cxf.endpoint.Endpoint ep = ((DispatchImpl<SOAPMessage>)dispatch).getClient().getEndpoint();
ep.put("propZ", "valueZ");
ClientConfigUtil.setConfigProperties(dispatch, null, testConfigName);
return (ep.get("propT").equals("valueT") && ep.get("propZ").equals("valueZ"));
}
finally
{
// -- remove test client configuration --
TestUtils.removeTestCaseClientConfiguration(testConfigName);
// --
}
}
示例7: testAddingIncomptiableHandler
import javax.xml.ws.Dispatch; //导入依赖的package包/类
@Test
@RunAsClient
public void testAddingIncomptiableHandler() throws Exception
{
try
{
Dispatch<Source> source = createDispatchSource();
@SuppressWarnings("rawtypes")
List<Handler> handlers = new ArrayList<Handler>();
handlers.add(new SOAPHandler());
source.getBinding().setHandlerChain(handlers);
fail("WebServiceException is not thrown");
}
catch (WebServiceException e)
{
//expected and do nothing
}
}
示例8: testCreateDispatchUsingEPRAndSource
import javax.xml.ws.Dispatch; //导入依赖的package包/类
@Test
@RunAsClient
public void testCreateDispatchUsingEPRAndSource() throws Exception
{
Dispatch<Source> dispatch = service.createDispatch(PORT_QNAME, Source.class, Mode.PAYLOAD);
assertNotNull("Dispatch is null", dispatch);
this.invokeSourceDispatch(dispatch);
epr = dispatch.getEndpointReference();
printEPR(epr);
dispatch = service.createDispatch(epr, Source.class, Service.Mode.PAYLOAD, ADDRESSING_ENABLED);
assertNotNull("Dispatch is null", dispatch);
this.invokeSourceDispatch(dispatch);
epr = dispatch.getEndpointReference();
printEPR(epr);
dispatch = service.createDispatch(epr, Source.class, Service.Mode.PAYLOAD, ADDRESSING_DISABLED);
assertNotNull("Dispatch is null", dispatch);
this.invokeSourceDispatch(dispatch);
epr = dispatch.getEndpointReference();
printEPR(epr);
}
示例9: testCreateDispatchUsingEPRAndJAXBContext
import javax.xml.ws.Dispatch; //导入依赖的package包/类
@Test
@RunAsClient
public void testCreateDispatchUsingEPRAndJAXBContext() throws Exception
{
Dispatch<Object> dispatch = service.createDispatch(PORT_QNAME, this.createJAXBContext(), Mode.PAYLOAD);
assertNotNull("Dispatch is null", dispatch);
this.invokeObjectDispatch(dispatch);
epr = dispatch.getEndpointReference();
printEPR(epr);
dispatch = service.createDispatch(epr, this.createJAXBContext(), Service.Mode.PAYLOAD, ADDRESSING_ENABLED);
assertNotNull("Dispatch is null", dispatch);
this.invokeObjectDispatch(dispatch);
epr = dispatch.getEndpointReference();
printEPR(epr);
dispatch = service.createDispatch(epr, this.createJAXBContext(), Service.Mode.PAYLOAD, ADDRESSING_DISABLED);
assertNotNull("Dispatch is null", dispatch);
this.invokeObjectDispatch(dispatch);
epr = dispatch.getEndpointReference();
printEPR(epr);
}
示例10: testProviderDispatch
import javax.xml.ws.Dispatch; //导入依赖的package包/类
@Test
@RunAsClient
public void testProviderDispatch() throws Exception
{
String targetNS = "http://ws.com/";
QName serviceName = new QName(targetNS, "Provider");
QName portName = new QName(targetNS, "ProviderPort");
Service service = Service.create(serviceName);
service.addPort(portName, HTTPBinding.HTTP_BINDING, baseURL.toString());
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
Source resPayload = dispatch.invoke(new DOMSource(DOMUtils.parse("<ns2:input xmlns:ns2='http://ws.com/'><arg0>hello</arg0></ns2:input>")));
Element docElement = DOMUtils.sourceToElement(resPayload);
Element response = ((Element)DOMUtils.getChildElements(docElement, "return").next());
assertEquals("hello", response.getTextContent());
}
示例11: testCustomClientConfigurationOnDispatchFromFile
import javax.xml.ws.Dispatch; //导入依赖的package包/类
public boolean testCustomClientConfigurationOnDispatchFromFile() throws Exception
{
final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
URL wsdlURL = new URL(address + "?wsdl");
Service service = Service.create(wsdlURL, serviceName);
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
BindingProvider bp = (BindingProvider)dispatch;
@SuppressWarnings("rawtypes")
List<Handler> hc = bp.getBinding().getHandlerChain();
hc.add(new UserHandler());
bp.getBinding().setHandlerChain(hc);
ClientConfigUtil.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");
Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
示例12: testCustomClientConfigurationFromFileUsingFeatureOnDispatch
import javax.xml.ws.Dispatch; //导入依赖的package包/类
public boolean testCustomClientConfigurationFromFileUsingFeatureOnDispatch() throws Exception
{
final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
URL wsdlURL = new URL(address + "?wsdl");
Service service = Service.create(wsdlURL, serviceName);
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD,
new ClientConfigFeature("META-INF/jaxws-client-config.xml", "Custom Client Config"));
BindingProvider bp = (BindingProvider)dispatch;
@SuppressWarnings("rawtypes")
List<Handler> hc = bp.getBinding().getHandlerChain();
hc.add(new UserHandler());
bp.getBinding().setHandlerChain(hc);
Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
示例13: createDispatch
import javax.xml.ws.Dispatch; //导入依赖的package包/类
public <T> Dispatch<T> createDispatch(Class<T> type, Mode mode) throws IOException {
if (this.wsdlService == null) {
Bus bus = BusFactory.getThreadDefaultBus();
BusFactory.setThreadDefaultBus(this.mcf.getBus());
try {
this.wsdlService = Service.create(this.mcf.getWsdlUrl(), this.mcf.getServiceQName());
} finally {
BusFactory.setThreadDefaultBus(bus);
}
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_WS, "Created the WSDL service for", this.mcf.getWsdl()); //$NON-NLS-1$
}
}
Dispatch<T> dispatch = this.wsdlService.createDispatch(this.mcf.getPortQName(), type, mode);
configureWSSecurity(dispatch);
setDispatchProperties(dispatch, "SOAP12"); //$NON-NLS-1$
return dispatch;
}
示例14: testWebService
import javax.xml.ws.Dispatch; //导入依赖的package包/类
@Test
@RunAsClient
public void testWebService() throws Exception
{
URL wsdlURL = new URL(baseURL + "?wsdl");
QName serviceName = new QName(targetNS, "PingEndpointService");
QName portName = new QName(targetNS, "PingEndpointPort");
Service service = Service.create(wsdlURL, serviceName);
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "uri:placeBuyOrder");
String payload = "<ns1:ping xmlns:ns1='" + targetNS + "'/>";
Source retObj = dispatch.invoke(new StreamSource(new StringReader(payload)));
Element docElement = DOMUtils.sourceToElement(retObj);
Element retElement = DOMUtils.getFirstChildElement(docElement);
assertEquals("return", retElement.getLocalName());
assertEquals("\"uri:placeBuyOrder\"", retElement.getFirstChild().getNodeValue());
}
示例15: testDocBareDispatchService
import javax.xml.ws.Dispatch; //导入依赖的package包/类
@Test
@RunAsClient
public void testDocBareDispatchService() throws Exception
{
QName serviceName = new QName(targetNS, "DocBareService");
QName portName = new QName(targetNS, "DocBarePort");
URL wsdlURL = new URL(baseURL + "/DocBareService?wsdl");
Service service = Service.create(wsdlURL, serviceName);
JAXBContext jbc = JAXBContext.newInstance(new Class[] { SubmitBareRequest.class, SubmitBareResponse.class });
@SuppressWarnings("rawtypes")
Dispatch dispatch = service.createDispatch(portName, jbc, Mode.PAYLOAD);
SubmitBareRequest poReq = new SubmitBareRequest("Ferrari");
@SuppressWarnings("unchecked")
SubmitBareResponse poRes = (SubmitBareResponse)dispatch.invoke(poReq);
assertEquals("Ferrari", poRes.getProduct());
}