use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class ClientTest method createDispatchJAXB.
Dispatch createDispatchJAXB() {
Service service = Service.create(new QName("urn:test", "Hello"));
JAXBContext context = createJAXBContext(ObjectFactory.class);
QName portQName = new QName("urn:test", "HelloPort");
service.addPort(portQName, "http://schemas.xmlsoap.org/wsdl/soap/http", helloPortAddress);
Dispatch dispatch = service.createDispatch(portQName, context, Service.Mode.PAYLOAD);
return dispatch;
}
use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class SOAPAction1Test method testSOAPActionWithDispatch_WithUse_false.
// since use property is false, action property is ineffective
public void testSOAPActionWithDispatch_WithUse_false() throws JAXBException {
TestEndpoint1 port = new TestEndpointService1().getTestEndpointPort1();
String address = (String) ((BindingProvider) port).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
Service s = Service.create(new QName("http://client.soapaction_use.server/", "TestEndpointService1"));
s.addPort(new QName("http://client.soapaction_use.server/", "TestEndpointPort1"), SOAPBinding.SOAP11HTTP_BINDING, address);
Dispatch<Object> d = s.createDispatch(new QName("http://client.soapaction_use.server/", "TestEndpointPort1"), JAXBContext.newInstance(ObjectFactory.class), Service.Mode.PAYLOAD);
((BindingProvider) d).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "http://example/action");
((BindingProvider) d).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, false);
JAXBElement<String> r = (JAXBElement<String>) d.invoke(new ObjectFactory().createEchoSOAPAction("dummy"));
assertEquals(empty_action, r.getValue());
}
use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class HttpContextTest method testAuthentication.
public void testAuthentication() throws Exception {
int port = PortAllocator.getFreePort();
String address = "http://localhost:" + port + "/hello";
HttpServer server = HttpServer.create(new InetSocketAddress(port), 5);
ExecutorService threads = Executors.newFixedThreadPool(5);
server.setExecutor(threads);
server.start();
Endpoint endpoint = Endpoint.create(new RpcLitEndpoint());
HttpContext context = server.createContext("/hello");
final String realm = "localhost.realm.com";
context.setAuthenticator(new BasicAuthenticator(realm) {
public boolean checkCredentials(String username, String password) {
System.out.println("Authenticator is called");
if (username.equals("auth-user") && password.equals("auth-pass")) {
return true;
}
return false;
}
});
endpoint.publish(context);
/*
Works but the next request hangs
// Gets WSDL from the published endpoint
int code = getHttpStatusCode(address);
assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, code);
*/
// access service
QName portName = new QName("http://echo.org/", "RpcLitPort");
QName serviceName = new QName("http://echo.org/", "RpcLitEndpoint");
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, address);
Dispatch<Source> d = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
d.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "auth-user");
d.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "auth-pass");
String body = "<ns0:echoInteger xmlns:ns0=\"http://echo.abstract.org/\"><arg0>2</arg0></ns0:echoInteger>";
Source request = new StreamSource(new ByteArrayInputStream(body.getBytes()));
Source response = d.invoke(request);
request = new StreamSource(new ByteArrayInputStream(body.getBytes()));
response = d.invoke(request);
endpoint.stop();
server.stop(1);
threads.shutdown();
}
use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class SubDomainTest method invoke.
private void invoke(String host, String address) {
// access service
QName portName = new QName("", "");
QName serviceName = new QName("", "");
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, address);
Dispatch<Source> d = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
Map<String, Object> requestContext = d.getRequestContext();
requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
// introduce() request
String body = "<ns2:introduce xmlns:ns2='urn:test'><arg0>" + host + "</arg0></ns2:introduce>";
Source request = new StreamSource(new ByteArrayInputStream(body.getBytes()));
d.invoke(request);
// rememeberMe() request
body = "<ns2:rememberMe xmlns:ns2='urn:test'/>";
request = new StreamSource(new ByteArrayInputStream(body.getBytes()));
d.invoke(request);
}
use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class WhitespaceTest method invoke.
private Source invoke(String address) throws Exception {
QName portName = new QName(NS, "RpcLitPort");
QName serviceName = new QName(NS, "RpcLitEndpoint");
Service service = Service.create(new URL(address + "?wsdl"), serviceName);
Dispatch<Source> d = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
String body = "<ns:add xmlns:ns='" + NS + "'> <arg0> 10 </arg0> <arg1> 20 </arg1> </ns:add>";
return d.invoke(new StreamSource(new StringReader(body)));
}
Aggregations