本文整理了Java中javax.wsdl.Service.getPort()
方法的一些代码示例,展示了Service.getPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Service.getPort()
方法的具体详情如下:
包路径:javax.wsdl.Service
类名称:Service
方法名:getPort
[英]Get the specified port.
[中]获取指定的端口。
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Change the port of the service.
*
* @param portName
* The new port name.
* @throws IllegalArgumentException
* if port name is not defined in WSDL.
*/
public void setPort( QName portName ) {
Port port = _service.getPort( portName.getLocalPart() );
if ( port == null ) {
throw new IllegalArgumentException( "Port name: '" + portName + "' was not found in the WSDL file." );
}
_port = port;
_operationCache.clear();
}
代码示例来源:origin: pentaho/pentaho-kettle
_port = getSoapPort( _service.getPorts().values() );
} else {
_port = _service.getPort( portName );
if ( _port == null ) {
throw new IllegalArgumentException( "Port: "
+ portName + " is not defined in the service: " + serviceQName );
} else {
_port = _service.getPort( portName );
代码示例来源:origin: pentaho/pentaho-kettle
public Wsdl( WSDLLocator wsdlLocator, QName serviceQName, String portName, String username, String password ) throws AuthenticationException {
// load and parse the WSDL
try {
_wsdlDefinition = parse( wsdlLocator, username, password );
} catch ( AuthenticationException ae ) {
// throw it again or KettleException will catch it
throw ae;
} catch ( WSDLException e ) {
throw new RuntimeException( "Could not load WSDL file: " + e.getMessage(), e );
} catch ( KettleException e ) {
throw new RuntimeException( "Could not load WSDL file: " + e.getMessage(), e );
}
_service = _wsdlDefinition.getService( serviceQName );
if ( _service == null ) {
throw new IllegalArgumentException( "Service: " + serviceQName + " is not defined in the WSDL file." );
}
_port = _service.getPort( portName );
if ( _port == null ) {
throw new IllegalArgumentException( "Port: " + portName + " is not defined in the service: " + serviceQName );
}
_wsdlTypes = new WsdlTypes( _wsdlDefinition );
_operationCache = new HashMap<String, WsdlOperation>();
}
代码示例来源:origin: stackoverflow.com
Service s = new Service();
Port port = s.getPort();
BindingProvider prov = (BindingProvider)port;
prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "myusername");
prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "mypassword");
port.call();
代码示例来源:origin: stackoverflow.com
private YourService proxy;
public YourServiceWrapper() {
try {
final String username = "username";
final String password = "password";
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
username,
password.toCharArray());
}
});
URL url = new URL("http://yourserviceurl/YourService?WSDL");
QName qname = new QName("http://targetnamespace/of/your/wsdl", "YourServiceNameInWsdl");
Service service = Service.create(url, qname);
proxy = service.getPort(YourService.class);
Map<String, Object> requestContext = ((BindingProvider) proxy).getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url.toString());
requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
Map<String, List<String>> headers = new HashMap<String, List<String>>();
requestContext.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
} catch (Exception e) {
LOGGER.error("Error occurred in web service client initialization", e);
}
}
代码示例来源:origin: stackoverflow.com
// Create the service
Service service = Service.create(urlToWsdl, serviceQName);
// Access the port
return service.getPort(serviceQName, portTypeClass);
代码示例来源:origin: stackoverflow.com
String wsdlDocumentLocation = "localVersion.wsdl";
QName serviceName = new QName("mynamespace", "myServiceName");
Service service = Service.create(wsdlDocumentLocation, serviceName);
//send the port the fully qualified name of the Metro generated
//client interface
Object port = service.getPort("my.client.package.ClientServiceInterface");
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
try {
Definition def = wsdlManager.getDefinition(wsdlDocumentLocation);
interfaceName = def.getService(serviceName).getPort(portName.getLocalPart()).getBinding()
.getPortType().getQName();
} catch (Exception e) {
代码示例来源:origin: stackoverflow.com
URL url = new URL("http://localhost:9090/ws/hello?wsdl");
//1st argument service URI, refer to wsdl document above
//2nd argument is service name, refer to wsdl document above
QName qname = new QName("http://ws.service.com/", "HelloWorldImplService");
Service service = Service.create(url, qname);
HelloWorld hellObj = service.getPort(HelloWorld.class);
代码示例来源:origin: stackoverflow.com
Service s = Service.create(
new URL("http://example.com/your_service?wsdl"),
new QName("http://example.com/your_namespace", "YourServiceName"));
ServiceInterface yourService = s.getPort(
new QName("http://example.com/your_namespace", "YourPortName"),
ServiceInterface.class);
代码示例来源:origin: stackoverflow.com
try {
URL wsdlURL = new URL("http://localhost:8082/cxf/services/yourservice?wsdl");
QName SERVICE_NAME = new QName("http://package.name/","PORTNAme");
Service service = Service.create(wsdlURL, SERVICE_NAME);
client = service.getPort(PORTInterface.class);
client.executeYourMethod()
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
代码示例来源:origin: stackoverflow.com
public class WSClient {
public static void main(String[] args) throws Exception {
URL url = new URL("http://localhost:8080/ws/hello?wsdl");
QName qname = new QName("http://bot.ws/", "HelloWorldImplService");
Service service = Service.create(url, qname);
HelloWorld hello = service.getPort(HelloWorld.class);
System.out.println(hello.getString("bot"));
}
}
代码示例来源:origin: stackoverflow.com
// Create the service
Service service = Service.create(serviceQName);
// Add a Port to the service and specify the SOAP 1.2 binding
service.addPort(serviceQName, javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING, wsUrl);
// Access the port
return service.getPort(serviceQName, portTypeClass);
代码示例来源:origin: org.apache.axis2/axis2-metadata
private Port getPort(QName serviceQname, QName eprQname) {
Service service = getService(serviceQname);
if (service == null) {
return null;
}
return service.getPort(eprQname.getLocalPart());
}
代码示例来源:origin: org.wso2.carbon.business-process/org.wso2.carbon.bpel
private Port getPortDefinition() {
Service serviceDef = wsdl.getService(serviceName);
if (serviceDef == null) {
throw new NullPointerException(Messages.msgServiceDefinitionNotFound(
serviceName.getLocalPart()));
}
return serviceDef.getPort(portName);
}
代码示例来源:origin: stackoverflow.com
URL wsdlURL = new URL("...");
QName serviceName = new QName("...", "...");
Service service = Service.create(wsdlURL, serviceName);
HandlerResolver handlerResolver = new ClientHandlerResolver();
service.setHandlerResolver(handlerResolver);
MyService myService = service.getPort(MyService.class);
// invoke methods (operations) on myService
代码示例来源:origin: stackoverflow.com
import javax.xml.ws.soap.MTOMFeature;
public class ArchiveMessageSerializer {
public String serializeArchiveReportWithDefTags(ArchiveMetadataType metaData) throws UnsupportedEncodingException {
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
RedirectionTransportFactory.getRegistry().registerRedirectionInThread(buffer);
final Service service = new Service();
final Port port = service.getPort(new MTOMFeature());
port.someMethod(metaData);
return buffer.toString("iso-8859-1");
}
}
代码示例来源:origin: org.apache.axis2/axis2-metadata
public Port getWSDLPort() {
javax.wsdl.Service service = getWSDLService();
if (service != null) {
return service.getPort(getPortQName().getLocalPart());
} else {
return null;
}
}
代码示例来源:origin: stackoverflow.com
Service service = Service.create(url, qname);
Greeting greeting = service.getPort(Greeting.class);
BindingProvider bp = (BindingProvider) greeting;
SOAPBinding binding = (SOAPBinding) bp.getBinding();
binding.setMTOMEnabled(true);
List<Handler> handlerList = new ArrayList<Handler>();
handlerList.add(new RGBSOAPHandler());
binding.setHandlerChain(handlerList);
代码示例来源:origin: org.wso2.bpel/ode-utils
/**
* @see #useHTTPBinding(javax.wsdl.Binding)
*/
public static boolean useHTTPBinding(Definition def, QName serviceName, String portName) {
Service serviceDef = def.getService(serviceName);
if (serviceDef == null)
throw new IllegalArgumentException(msgs.msgServiceDefinitionNotFound(serviceName));
Port port = serviceDef.getPort(portName);
if (port == null)
throw new IllegalArgumentException(msgs.msgPortDefinitionNotFound(serviceName, portName));
return useHTTPBinding(port);
}
内容来源于网络,如有侵权,请联系作者删除!