本文整理了Java中javax.xml.ws.Service.getPort()
方法的一些代码示例,展示了Service.getPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Service.getPort()
方法的具体详情如下:
包路径:javax.xml.ws.Service
类名称:Service
方法名:getPort
[英]The getPort method returns a proxy. The parameter serviceEndpointInterface specifies the service endpoint interface that is supported by the returned proxy. In the implementation of this method, the JAX-WS runtime system takes the responsibility of selecting a protocol binding (and a port) and configuring the proxy accordingly. The returned proxy should not be reconfigured by the client.
[中]getPort方法返回一个代理。参数serviceEndpointInterface指定返回的代理所支持的服务端点接口。在该方法的实现中,JAX-WS运行时系统负责选择协议绑定(和端口)并相应地配置代理。客户端不应重新配置返回的代理。
代码示例来源:origin: pentaho/pentaho-kettle
@Override public boolean test() {
String repoUrl = repositoryMeta.getRepositoryLocation().getUrl();
final String url = repoUrl + ( repoUrl.endsWith( "/" ) ? "" : "/" ) + "webservices/unifiedRepository?wsdl";
Service service;
try {
service = Service.create( new URL( url ), new QName( "http://www.pentaho.org/ws/1.0", "unifiedRepository" ) );
if ( service != null ) {
IUnifiedRepositoryJaxwsWebService repoWebService = service.getPort( IUnifiedRepositoryJaxwsWebService.class );
if ( repoWebService != null ) {
return true;
}
}
} catch ( Exception e ) {
return false;
}
return false;
}
代码示例来源:origin: stagemonitor/stagemonitor
@Test
public void test() throws Exception {
QName serviceName = new QName("http://www.jboss.org/jbossas/quickstarts/wshelloworld/HelloWorld", "HelloWorldService");
Service service = Service.create(new URL("http://localhost:" + getPort()), serviceName);
HelloWorldService helloWorldService = service.getPort(HelloWorldService.class);
assertThat(helloWorldService).isInstanceOf(BindingProvider.class);
final BindingProvider bindingProvider = (BindingProvider) helloWorldService;
boolean clientHandlerFound = false;
for (Handler handler : bindingProvider.getBinding().getHandlerChain()) {
if (handler instanceof TracingClientSOAPHandler) {
clientHandlerFound = true;
}
}
assertThat(clientHandlerFound).overridingErrorMessage("No %s found in %s",
TracingClientSOAPHandler.class.getSimpleName(),
bindingProvider.getBinding().getHandlerChain()).isTrue();
}
代码示例来源:origin: apache/cxf
@Test
public void testClientServer() throws Exception {
Bus bus = new SpringBusFactory().createBus("org/apache/cxf/systest/ws/security/handler/client.xml");
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
Service service = Service.create(new URL("http://localhost:" + PORT + "/wsse/HelloWorldWS?wsdl"),
new QName("http://cxf.apache.org/wsse/handler/helloworld",
"HelloWorldImplService"));
QName portName = new QName("http://cxf.apache.org/wsse/handler/helloworld", "HelloWorldPort");
HelloWorld port = service.getPort(portName, HelloWorld.class);
updateAddressPort(port, PORT);
assertEquals("Hello CXF", port.sayHello("CXF"));
bus.shutdown(true);
}
代码示例来源:origin: apache/cxf
@org.junit.Test
public void testSignedSAML() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ActionTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSignedSAMLPort");
DoubleItPortType port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
assertEquals(50, port.doubleIt(25));
((java.io.Closeable)port).close();
bus.shutdown(true);
}
代码示例来源:origin: apache/cxf
@Test
public void testDocLitWrappedCodeFirstServiceWsdl() throws Exception {
QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",
"DocLitWrappedCodeFirstServicePort");
QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",
"DocLitWrappedCodeFirstService");
Service service = Service.create(new URL(ServerMisc.DOCLIT_CODEFIRST_URL + "?wsdl"),
servName);
DocLitWrappedCodeFirstService port = service.getPort(portName,
DocLitWrappedCodeFirstService.class);
runDocLitTest(port);
}
代码示例来源:origin: pentaho/pentaho-kettle
@Override
public Object call() throws Exception {
Service service = Service.create( url, new QName( NAMESPACE_URI, serviceName ) );
T port = service.getPort( clazz );
// add TRUST_USER if necessary
if ( StringUtils.isNotBlank( System.getProperty( "pentaho.repository.client.attemptTrust" ) ) ) {
( (BindingProvider) port ).getRequestContext().put( MessageContext.HTTP_REQUEST_HEADERS,
Collections.singletonMap( TRUST_USER, Collections.singletonList( username ) ) );
} else {
// http basic authentication
( (BindingProvider) port ).getRequestContext().put( BindingProvider.USERNAME_PROPERTY, username );
( (BindingProvider) port ).getRequestContext().put( BindingProvider.PASSWORD_PROPERTY, password );
}
// accept cookies to maintain session on server
( (BindingProvider) port ).getRequestContext().put( BindingProvider.SESSION_MAINTAIN_PROPERTY, true );
// support streaming binary data
// TODO mlowery this is not portable between JAX-WS implementations (uses com.sun)
( (BindingProvider) port ).getRequestContext().put( JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE,
8192 );
SOAPBinding binding = (SOAPBinding) ( (BindingProvider) port ).getBinding();
binding.setMTOMEnabled( true );
return port;
}
} );
代码示例来源:origin: apache/cxf
@org.junit.Test
public void testTransformFeature() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = StaxTransformFeatureTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = StaxTransformFeatureTest.class.getResource("DoubleItTransform.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItPlaintextPort2");
DoubleItPortType2 port =
service.getPort(portQName, DoubleItPortType2.class);
updateAddressPort(port, PORT);
assertEquals(50, port.doubleIt2(25));
((java.io.Closeable)port).close();
bus.shutdown(true);
}
代码示例来源:origin: apache/cxf
@Test
public void testRpcLitWsdl() throws Exception {
QName portName = new QName("http://cxf.apache.org/systest/jaxws/RpcLitCodeFirstService",
"RpcLitCodeFirstServicePort");
QName servName = new QName("http://cxf.apache.org/systest/jaxws/RpcLitCodeFirstService",
"RpcLitCodeFirstService");
Service service = Service.create(new URL(ServerMisc.RPCLIT_CODEFIRST_URL + "?wsdl"),
servName);
RpcLitCodeFirstService port = service.getPort(portName,
RpcLitCodeFirstService.class);
runRpcLitTest(port);
}
代码示例来源:origin: pentaho/pentaho-kettle
Service service;
try {
service = Service.create( new URL( url ), new QName( "http://www.pentaho.org/ws/1.0", "unifiedRepository" ) ); //$NON-NLS-1$ //$NON-NLS-2$
if ( service != null ) {
IUnifiedRepositoryJaxwsWebService repoWebService = service.getPort( IUnifiedRepositoryJaxwsWebService.class );
if ( repoWebService != null ) {
messageBox.setTitle( BaseMessages.getString( PurRepositoryDialog.class, "Dialog.Success" ) );//$NON-NLS-1$
代码示例来源:origin: apache/cxf
@org.junit.Test
public void test3DESEncryptionGivenKey() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ActionTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleIt3DESEncryptionPort");
DoubleItPortType port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
assertEquals(50, port.doubleIt(25));
((java.io.Closeable)port).close();
bus.shutdown(true);
}
代码示例来源:origin: apache/cxf
@Test
public void testDocLitWrappedCodeFirstServiceNoWsdl() throws Exception {
QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",
"DocLitWrappedCodeFirstServicePort");
QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",
"DocLitWrappedCodeFirstService");
Service service = Service.create(servName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, ServerMisc.DOCLIT_CODEFIRST_URL);
DocLitWrappedCodeFirstService port = service.getPort(portName,
DocLitWrappedCodeFirstService.class);
runDocLitTest(port);
}
代码示例来源:origin: apache/cxf
@org.junit.Test
public void testBasicAuth() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = BasicAuthTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = BasicAuthTest.class.getResource("DoubleItBasicAuth.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItBasicAuthPort");
DoubleItPortType utPort =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(utPort, PORT);
assertEquals(50, utPort.doubleIt(25));
((java.io.Closeable)utPort).close();
bus.shutdown(true);
}
代码示例来源:origin: apache/cxf
@Test
public void testHelloSoap() throws Exception {
final QName serviceName = new QName("http://hello.com", "HelloWorld");
final QName portName = new QName("http://hello.com", "HelloWorldPort");
final String address = "http://localhost:" + PORT + "/test/services/hello-soap";
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, address);
HelloWorld hw = service.getPort(HelloWorld.class);
useHelloService(hw);
}
代码示例来源:origin: apache/cxf
@org.junit.Test
public void testAsymmetricEncryptBeforeSigningActionToPolicy() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ActionTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricEncryptBeforeSigningPort");
DoubleItPortType port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
// Successful call
assertEquals(50, port.doubleIt(25));
((java.io.Closeable)port).close();
bus.shutdown(true);
}
代码示例来源:origin: apache/cxf
@Test
public void testRpcLitNoWsdl() throws Exception {
QName portName = new QName("http://cxf.apache.org/systest/jaxws/RpcLitCodeFirstService",
"RpcLitCodimlpementor6eFirstServicePort");
QName servName = new QName("http://cxf.apache.org/systest/jaxws/RpcLitCodeFirstService",
"RpcLitCodeFirstService");
Service service = Service.create(servName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, ServerMisc.RPCLIT_CODEFIRST_URL);
RpcLitCodeFirstService port = service.getPort(portName,
RpcLitCodeFirstService.class);
runRpcLitTest(port);
}
代码示例来源:origin: apache/cxf
@org.junit.Test
public void testEncryption() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ActionTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItEncryptionPort");
DoubleItPortType port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
// Successful call
assertEquals(50, port.doubleIt(25));
((java.io.Closeable)port).close();
bus.shutdown(true);
}
代码示例来源:origin: apache/cxf
@Test
public void testHelloSoap() throws Exception {
final QName serviceName = new QName("http://hello.com", "HelloWorld");
final QName portName = new QName("http://hello.com", "HelloWorldPort");
final String address = "http://localhost:" + PORT + "/bp/services/hello-soap";
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, address);
HelloWorld hw = service.getPort(HelloWorld.class);
useHelloService(hw);
}
private void useHelloService(HelloWorld service) {
代码示例来源:origin: apache/cxf
@org.junit.Test
public void testAsymmetricBytesInAttachment() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = MTOMSecurityTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = MTOMSecurityTest.class.getResource("DoubleItMtom.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricPort");
DoubleItPortType port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
int result = port.doubleIt(25);
assertEquals(result, 50);
((java.io.Closeable)port).close();
bus.shutdown(true);
}
代码示例来源:origin: apache/cxf
@Test
public void testBasicConnection() throws Exception {
QName serviceName = new QName("http://type_substitution.systest.cxf.apache.org/",
"AppleFinder");
QName portName = new QName("http://type_substitution.systest.cxf.apache.org/", "AppleFinderPort");
Service service = Service.create(serviceName);
String endpointAddress = "http://localhost:" + PORT + "/appleFind";
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
AppleFinder finder = service.getPort(AppleFinder.class);
assertEquals(2, finder.getApple("Fuji").size());
}
代码示例来源:origin: apache/cxf
@org.junit.Test
public void testActionBytesInAttachment() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = MTOMSecurityTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = MTOMSecurityTest.class.getResource("DoubleItMtom.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItActionPort");
DoubleItPortType port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
int result = port.doubleIt(25);
assertEquals(result, 50);
((java.io.Closeable)port).close();
bus.shutdown(true);
}
内容来源于网络,如有侵权,请联系作者删除!