@Test public void testParsedInterfaceName() throws Exception { W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder = builder.address(URL); Element element = DOMUtils.parse(XML_INTERFACE_NAME); builder = builder.metadata(element); builder = builder.serviceName(SERVICE_QNAME); builder = builder.endpointName(PORT_QNAME); builder = builder.wsdlDocumentLocation(WSDL_URL); element = DOMUtils.parse(XML_REF_PARAM1); builder = builder.referenceParameter(element); element = DOMUtils.parse(XML_REF_PARAM2); builder = builder.referenceParameter(element); W3CEndpointReference epr = builder.build(); DOMResult dr = new DOMResult(); epr.writeTo(dr); Node endpointReferenceElement = dr.getNode(); Logger.getLogger(this.getClass()).info(DOMUtils.node2String(endpointReferenceElement)); assertMetaData(endpointReferenceElement); assertRefParam(endpointReferenceElement, PARAM1_QNAME, "Hello"); assertRefParam(endpointReferenceElement, PARAM2_QNAME, "World"); }
@Test public void testConstructedInterfaceName() throws Exception { W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder = builder.address(URL); builder = builder.serviceName(SERVICE_QNAME); builder = builder.endpointName(PORT_QNAME); builder = builder.interfaceName(PORT_TYPE_QNAME); builder = builder.wsdlDocumentLocation(WSDL_URL); Element element = DOMUtils.parse(XML_REF_PARAM1); builder = builder.referenceParameter(element); element = DOMUtils.parse(XML_REF_PARAM2); builder = builder.referenceParameter(element); W3CEndpointReference epr = builder.build(); DOMResult dr = new DOMResult(); epr.writeTo(dr); Node endpointReferenceElement = dr.getNode(); Logger.getLogger(this.getClass()).info(DOMUtils.node2String(endpointReferenceElement)); assertMetaData(endpointReferenceElement); assertRefParam(endpointReferenceElement, PARAM1_QNAME, "Hello"); assertRefParam(endpointReferenceElement, PARAM2_QNAME, "World"); }
/** * Instantiates underlying service. * @param clazz webservice class * @param serviceLocation webservice location * @param serviceReadTimeout service read timeout * @param serviceConnectionTimeout service connection timeout * @param resultSetReadTimeout resultset read timeout * @param resultSetConnectionTimeout resultset connection timeout * @param resultSetPageSize resultset page size */ protected AbstractResultSetAwareWebServiceFacade(Class<T> clazz, String serviceLocation, long serviceReadTimeout, long serviceConnectionTimeout, long resultSetReadTimeout, long resultSetConnectionTimeout, int resultSetPageSize) { W3CEndpointReferenceBuilder eprBuilder = new W3CEndpointReferenceBuilder(); eprBuilder.address(serviceLocation); eprBuilder.build(); this.service = new JaxwsServiceResolverImpl().getService(clazz, eprBuilder.build()); if (this.service instanceof BindingProvider) { log.info(String.format("setting timeouts for %s: read timeout (%s) and connect timeout (%s)", BindingProvider.class, serviceReadTimeout, serviceConnectionTimeout)); final Map<String, Object> requestContext = ((BindingProvider) service).getRequestContext(); // can't be sure about which will be used. Set them all. requestContext.put("com.sun.xml.internal.ws.request.timeout", serviceReadTimeout); requestContext.put("com.sun.xml.internal.ws.connect.timeout", serviceConnectionTimeout); requestContext.put("com.sun.xml.ws.request.timeout", serviceReadTimeout); requestContext.put("com.sun.xml.ws.connect.timeout", serviceConnectionTimeout); requestContext.put("javax.xml.ws.client.receiveTimeout", serviceReadTimeout); requestContext.put("javax.xml.ws.client.connectionTimeout", serviceConnectionTimeout); } this.resultSetReadTimeout = resultSetReadTimeout; this.resultSetConnectionTimeout = resultSetConnectionTimeout; this.resultSetPageSize = resultSetPageSize; }
@Override public void setUp() throws Exception { super.setUp(); W3CEndpointReferenceBuilder w3cBuilder = new W3CEndpointReferenceBuilder(); w3cBuilder = w3cBuilder.address("http://somewhere.com/somehow"); w3cBuilder = w3cBuilder.serviceName(new QName("http://test", "TestService")); w3cBuilder = w3cBuilder.endpointName(new QName("http://test", "TestPort")); w3cEPR = w3cBuilder.build(); SubmissionEndpointReferenceBuilder subBuilder = new SubmissionEndpointReferenceBuilder(); subBuilder = subBuilder.address("http://somewhere.com/somehow"); subBuilder = subBuilder.serviceName(new QName("http://test", "TestService")); subBuilder = subBuilder.endpointName(new QName("http://test", "TestPort")); subEPR = subBuilder.build(); }
@Override public void setUp() throws Exception { super.setUp(); W3CEndpointReferenceBuilder w3cBuilder = new W3CEndpointReferenceBuilder(); w3cBuilder = w3cBuilder.address("http://somewhere.com/somehow"); w3cBuilder = w3cBuilder.serviceName(new QName("http://test", "ProxyAddressingService")); w3cBuilder = w3cBuilder.endpointName(new QName("http://test", "TestPort")); w3cEPR = w3cBuilder.build(); SubmissionEndpointReferenceBuilder subBuilder = new SubmissionEndpointReferenceBuilder(); subBuilder = subBuilder.address("http://somewhere.com/somehow"); subBuilder = subBuilder.serviceName(new QName("http://test", "ProxyAddressingService")); subBuilder = subBuilder.endpointName(new QName("http://test", "TestPort")); subEPR = subBuilder.build(); }
@Override public void setUp() throws Exception { super.setUp(); W3CEndpointReferenceBuilder w3cBuilder = new W3CEndpointReferenceBuilder(); w3cBuilder = w3cBuilder.address("http://somewhere.com/somehow"); w3cBuilder = w3cBuilder.serviceName(new QName("http://test", "ProxySessionService")); w3cBuilder = w3cBuilder.endpointName(new QName("http://test", "TestPort")); w3cEPR = w3cBuilder.build(); SubmissionEndpointReferenceBuilder subBuilder = new SubmissionEndpointReferenceBuilder(); subBuilder = subBuilder.address("http://somewhere.com/somehow"); subBuilder = subBuilder.serviceName(new QName("http://test", "ProxySessionService")); subBuilder = subBuilder.endpointName(new QName("http://test", "TestPort")); subEPR = subBuilder.build(); }
@Override public void setUp() throws Exception { super.setUp(); W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder = builder.address("http://somewhere.com/somehow"); builder = builder.serviceName(new QName("http://test", "ProxyAddressingService")); builder = builder.endpointName(new QName("http://test", "TestPort")); w3cEPR = builder.build(); SubmissionEndpointReferenceBuilder subBuilder = new SubmissionEndpointReferenceBuilder(); subBuilder = subBuilder.address("http://somewhere.com/somehow"); subBuilder = subBuilder.serviceName(new QName("http://test", "ProxyAddressingService")); subBuilder = subBuilder.endpointName(new QName("http://test", "TestPort")); subEPR = subBuilder.build(); }
@Override public void setUp() throws Exception { super.setUp(); W3CEndpointReferenceBuilder w3cBuilder = new W3CEndpointReferenceBuilder(); w3cBuilder = w3cBuilder.address("http://somewhere.com/somehow"); w3cBuilder = w3cBuilder.serviceName(new QName("http://test", "TestService")); w3cBuilder = w3cBuilder.endpointName(new QName("http://test", "TestPort")); w3cEPR = w3cBuilder.build(); SubmissionEndpointReferenceBuilder subBuilder = new SubmissionEndpointReferenceBuilder(); subBuilder = subBuilder.address("http://somewhere.com/somehow"); subBuilder = subBuilder.serviceName(new QName("http://test", "TestService")); subBuilder = subBuilder.endpointName(new QName("http://test", "TestPort")); subBuilder.build(); }
@Override public UserProfileServiceWS newUserProfileService(String endpoint, String endpointChangeService, Map<String, List<String>> requestHeaders) { EndpointReference endpointRef = new W3CEndpointReferenceBuilder() .address(endpoint).build(); EndpointReference endpointChangeRef = new W3CEndpointReferenceBuilder() .address(endpointChangeService).build(); UserProfileServiceSoap inUserProfileServiceSoap = userProfileServiceSoap.getPort( endpointRef, UserProfileServiceSoap.class); UserProfileChangeServiceSoap inUserProfileChangeServiceSoap = userProfileChangeServiceSoap.getPort( endpointChangeRef, UserProfileChangeServiceSoap.class); ((BindingProvider) inUserProfileServiceSoap).getRequestContext().put( MessageContext.HTTP_REQUEST_HEADERS, requestHeaders); ((BindingProvider) inUserProfileChangeServiceSoap).getRequestContext() .put(MessageContext.HTTP_REQUEST_HEADERS, requestHeaders); addSocketTimeoutConfiguration((BindingProvider) inUserProfileServiceSoap); addSocketTimeoutConfiguration( (BindingProvider) inUserProfileChangeServiceSoap); return new SharePointUserProfileServiceWS(inUserProfileServiceSoap, inUserProfileChangeServiceSoap); }
public EndpointReference getEndpointReference(Element... referenceParameters) { org.apache.cxf.message.Message msg = getWrappedMessage(); Endpoint ep = msg.getExchange().get(Endpoint.class); W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address(ep.getEndpointInfo().getAddress()); builder.serviceName(ep.getService().getName()); builder.endpointName(ep.getEndpointInfo().getName()); if (referenceParameters != null) { for (Element referenceParameter : referenceParameters) { builder.referenceParameter(referenceParameter); } } return builder.build(); }
@Test @RunAsClient public void testEmptyMetadataDropped() { W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address("http://bar"); W3CEndpointReference epr = builder.build(); StringWriter writer = new StringWriter(); epr.writeTo(new StreamResult(writer)); String eprString = writer.toString(); assertTrue(eprString.contains("EndpointReference")); assertTrue(eprString.contains("Address")); assertFalse(eprString.contains("Metadata")); }
public static void main(String[] args) { String objectStoreServiceLocation = "http://beta.services.openaire.eu:8280/is/services/objectStore"; W3CEndpointReferenceBuilder eprBuilder = new W3CEndpointReferenceBuilder(); eprBuilder.address(objectStoreServiceLocation); eprBuilder.build(); ObjectStoreService objectStore = new JaxwsServiceResolverImpl().getService(ObjectStoreService.class, eprBuilder.build()); System.out.println(StringUtils.join(objectStore.getListOfObjectStores(), ',')); }
@Override public AuthenticationSoap newSharePointFormsAuthentication( String virtualServer, String username, String password) throws IOException { String authenticationEndPoint = spUrlToUri(virtualServer + "/_vti_bin/Authentication.asmx").toString(); EndpointReference endpointRef = new W3CEndpointReferenceBuilder() .address(handleEncoding(authenticationEndPoint)).build(); authenticationService.getPort(endpointRef, AuthenticationSoap.class); return authenticationService.getPort(endpointRef, AuthenticationSoap.class); }
/** * Creates a {@link org.oasis_open.docs.wsn.b_2.Notify}-object. * @param messageCount The count of {@link org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType}, i.e. NotificationMessages. * @param messageContent The content of all messages. Must be of same length as the messageCount parameter. * @param endpoint The endpoint's of all messages. Must be of same length as the messageCount parameter. * @param producerReference The reference to the producer of the NotificationMessages. Must be of same length as the messageCount parameter. * @param topic The topics for each message. Must be of same length as the messageCount parameter. * @param any Anything else. Must be of same length as the messageCount parameter. * @return A {@link org.oasis_open.docs.wsn.b_2.Notify} object. */ public static Notify createNotify(int messageCount, @Nonnull Object[] messageContent, @Nonnull String[] endpoint, @Nullable String[] producerReference, @Nullable TopicExpressionType[] topic, @Nullable Object[] any){ if(messageCount <= 0){ throw new IllegalArgumentException("MessageCount has to be larger than 0"); } if(producerReference != null){ if(messageCount != producerReference.length){ throw new IllegalArgumentException("The MessageCount passed in did not match the count of producerreference"); } } if(topic != null){ if(messageCount != topic.length){ throw new IllegalArgumentException("The MessageCount passed in did not match the count of topics"); } } if(messageCount != endpoint.length){ throw new IllegalArgumentException("The MessageCount passed in did not match the count of endpoints"); } if(messageCount != messageContent.length){ throw new IllegalArgumentException("The MessageCount passed in did not match the count of Messages"); } Notify notify = new Notify(); List<NotificationMessageHolderType> notificationMessages = notify.getNotificationMessage(); for (int i = 0; i < messageCount; i++) { NotificationMessageHolderType notificationMessage = new NotificationMessageHolderType(); NotificationMessageHolderType.Message message = new NotificationMessageHolderType.Message(); /* Set message */ Class messageClass = messageContent[i].getClass(); message.setAny(messageClass.cast(messageContent[i])); notificationMessage.setMessage(message); /* Create endpoint reference */ W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address(endpoint[i]); notificationMessage.setSubscriptionReference(builder.build()); /* Create producer reference */ if(producerReference != null){ builder.address(producerReference[i]); notificationMessage.setProducerReference(builder.build()); } if(topic != null){ notificationMessage.setTopic(topic[i]); } notificationMessages.add(notificationMessage); } if(any != null){ for (Object o : any) { notify.getAny().add(o); } } return notify; }
/** * @return the endpoint reference of the Web Service in the form of a {@link javax.xml.ws.wsaddressing.W3CEndpointReference} object. */ public W3CEndpointReference getEndpointReferenceAsW3C() { W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address(endpointReference); return builder.build(); }
/** * An implementation of the WS-N specification's RegisterPublisher. * * The implementation is designed to conform fully to the specification. Any specific can be found at * * <href>http://docs.oasis-open.org/wsn/wsn-ws_brokered_notification-1.3-spec-os.htm#_Toc133294203</href> * * @param registerPublisherRequest The register publisher object * @return A RegisterPublisherResponse containing the endpoint of the registration. * @throws InvalidTopicExpressionFault If topic expression dialect is unknown. * @throws PublisherRegistrationFailedFault This can be thrown in a number of circumstances. If any general internal error occurs, this is thrown. * @throws ResourceUnknownFault Never thrown as of version 0.4. * @throws PublisherRegistrationRejectedFault Never thrown. A {@link org.oasis_open.docs.wsn.brw_2.PublisherRegistrationFailedFault} is always thrown instead. * @throws UnacceptableInitialTerminationTimeFault If the termination time was invalid * @throws TopicNotSupportedFault If the Topic given is not a supported topic expression. */ @Override @WebResult(name = "RegisterPublisherResponse", targetNamespace = "http://docs.oasis-open.org/wsn/br-2", partName = "RegisterPublisherResponse") @WebMethod(operationName = "RegisterPublisher") public RegisterPublisherResponse registerPublisher( @WebParam(partName = "RegisterPublisherRequest",name = "RegisterPublisher", targetNamespace = "http://docs.oasis-open.org/wsn/br-2") RegisterPublisher registerPublisherRequest) throws InvalidTopicExpressionFault, PublisherRegistrationFailedFault, ResourceUnknownFault, PublisherRegistrationRejectedFault, UnacceptableInitialTerminationTimeFault, TopicNotSupportedFault { //NamespaceContext namespaceContext = connection.getRequestInformation().getNamespaceContext(); NuNamespaceContextResolver namespaceContextResolver = connection.getRequestInformation().getNamespaceContextResolver(); W3CEndpointReference publisherEndpoint = registerPublisherRequest.getPublisherReference(); if(publisherEndpoint == null){ ExceptionUtilities.throwPublisherRegistrationFailedFault("en", "Missing endpointreference"); } String endpointReference = ServiceUtilities.getAddress(registerPublisherRequest.getPublisherReference()); // EndpointReference is returned as "" from getAddress if something went wrong. if(endpointReference.equals("")){ ExceptionUtilities.throwPublisherRegistrationFailedFault("en", "Could not register publisher, failed to " + "understand the endpoint reference"); } List<TopicExpressionType> topics = registerPublisherRequest.getTopic(); for (TopicExpressionType topic : topics) { try { if(!TopicValidator.isLegalExpression(topic, namespaceContextResolver.resolveNamespaceContext(topic))){ ExceptionUtilities.throwTopicNotSupportedFault("en", "Expression given is not a legal topicexpression"); } } catch (TopicExpressionDialectUnknownFault topicExpressionDialectUnknownFault) { ExceptionUtilities.throwInvalidTopicExpressionFault("en", "TopicExpressionDialect unknown"); } } long terminationTime = registerPublisherRequest.getInitialTerminationTime().toGregorianCalendar().getTimeInMillis(); if(terminationTime < System.currentTimeMillis()){ ExceptionUtilities.throwUnacceptableInitialTerminationTimeFault("en", "Invalid termination time. Can't be before current time"); } String newSubscriptionKey = generateSubscriptionKey(); String subscriptionEndpoint = generateHashedURLFromKey(WsnUtilities.publisherRegistrationString, newSubscriptionKey); // Send subscriptionRequest back if isDemand isRequested if(registerPublisherRequest.isDemand()){ WsnUtilities.sendSubscriptionRequest(endpointReference, getEndpointReference(), getHub()); } publishers.put(newSubscriptionKey, new PublisherHandle(new HelperClasses.EndpointTerminationTuple(newSubscriptionKey, terminationTime), topics, registerPublisherRequest.isDemand())); RegisterPublisherResponse response = new RegisterPublisherResponse(); W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address(subscriptionEndpoint); response.setConsumerReference(builder.build()); response.setPublisherRegistrationReference(publisherEndpoint); return response; }
@Override public SiteDataSoap newSiteData(String endpoint) { EndpointReference endpointRef = new W3CEndpointReferenceBuilder() .address(handleEncoding(endpoint)).build(); return siteDataService.getPort(endpointRef, SiteDataSoap.class); }
@Override public UserGroupSoap newUserGroup(String endpoint) { EndpointReference endpointRef = new W3CEndpointReferenceBuilder() .address(handleEncoding(endpoint)).build(); return userGroupService.getPort(endpointRef, UserGroupSoap.class); }
@Override public PeopleSoap newPeople(String endpoint) { EndpointReference endpointRef = new W3CEndpointReferenceBuilder() .address(handleEncoding(endpoint)).build(); return peopleService.getPort(endpointRef, PeopleSoap.class); }
/** * Create a new endpoint reference for the given address, using the * specified reference parameters. * * @param sAddress * The address to use. May not be <code>null</code>. * @param aReferenceParameters * The non-<code>null</code> list of reference parameters. May * not be <code>null</code>. * @return The non-<code>null</code> endpoint reference for the given * address */ public static W3CEndpointReference createEndpointReference( final String sAddress, final List<Element> aReferenceParameters) { W3CEndpointReferenceBuilder aBuilder = new W3CEndpointReferenceBuilder() .address(sAddress); for (final Element aReferenceParameter : aReferenceParameters) { aBuilder = aBuilder.referenceParameter(aReferenceParameter); } return aBuilder.build(); }
/** * Create a new endpoint reference for the given address without reference * parameters. * * @param sAddress * The address to use. May not be <code>null</code>. * @return The non-<code>null</code> endpoint reference for the given * address */ public static W3CEndpointReference createEndpointReference( final String sAddress) { return new W3CEndpointReferenceBuilder().address(sAddress).build(); }