Java Code Examples for javax.xml.ws.Service

The following are top voted examples for showing how to use javax.xml.ws.Service. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: oscm-app   File: BesDAOTest.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
private BesDAO mockWebServiceSetup(
        final Map<String, Setting> proxySettings,
        final Map<String, Setting> controllerSettings)
        throws APPlatformException, MalformedURLException {
    BesDAO besDAO = spy(new BesDAO());
    besDAO.configService = spy(new APPConfigurationServiceBean());
    doReturn(proxySettings).when(besDAO.configService)
            .getAllProxyConfigurationSettings();
    if (controllerSettings != null) {
        doReturn(controllerSettings).when(besDAO.configService)
                .getControllerConfigurationSettings(anyString());
    }
    doReturn(mock(Service.class)).when(besDAO).createWebService(
            any(URL.class), any(QName.class));
    doReturn(idServ).when(besDAO).getServicePort(eq(IdentityService.class),
            anyMap());
    doReturn(subServ).when(besDAO).getServicePort(
            eq(SubscriptionService.class), anyMap());
    return besDAO;
}
 
Example 2
Project: oscm   File: BesDAOTest.java   View source code 6 votes vote down vote up
@Test
public void getServicePort() throws MalformedURLException {
    // given
    Map<String, Setting> settings = getSettingsForMode("SAML_SP");
    IdentityService idSvcMock = Mockito.mock(IdentityService.class);
    Service serviceMock = Mockito.mock(Service.class);
    doReturn(serviceMock).when(besDAO).createWebService(any(URL.class),
            any(QName.class));
    when(
            serviceMock.getPort(Matchers.any(QName.class),
                    eq(IdentityService.class))).thenReturn(idSvcMock);

    // when
    IdentityService idSvc = besDAO.getServicePort(IdentityService.class,
            settings);

    // then
    assertTrue(IdentityService.class.isAssignableFrom(idSvc.getClass()));
}
 
Example 3
Project: oscm   File: BesDAOTest.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void getBESWebService_nullInstance() throws MalformedURLException,
        APPlatformException {
    // given
    BesDAO besDAO = spy(new BesDAO());
    besDAO.configService = spy(new APPConfigurationServiceBean());
    Map<String, Setting> settings = getSettingsForMode("INTERNAL");
    doReturn(settings).when(besDAO.configService)
            .getAllProxyConfigurationSettings();
    Service serviceMock = Mockito.mock(Service.class);
    doReturn(serviceMock).when(besDAO).createWebService(any(URL.class),
            any(QName.class));
    doReturn(idServ).when(besDAO).getServicePort(eq(IdentityService.class),
            anyMap());
    doReturn(new PasswordAuthentication("user", "password")).when(
            besDAO.configService).getAuthenticationForAPPAdmin(anyMap());

    // when
    besDAO.getBESWebService(IdentityService.class, null, Optional.empty());

    // then
    verify(besDAO.configService, times(1)).getAuthenticationForAPPAdmin(
            anyMap());
}
 
Example 4
Project: openjdk-jdk10   File: Stubs.java   View source code 6 votes vote down vote up
/**
 * 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());
}
 
Example 5
Project: openjdk-jdk10   File: Stubs.java   View source code 6 votes vote down vote up
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @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 epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
 
Example 6
Project: openjdk-jdk10   File: WSServiceDelegate.java   View source code 6 votes vote down vote up
protected Dispatch<Object> createDispatch(QName portName, JAXBContext jaxbContext, Service.Mode mode, WebServiceFeatureList features) {
    WSEndpointReference wsepr = null;
    boolean isAddressingEnabled = false;
    AddressingFeature af = features.get(AddressingFeature.class);
    if (af == null) {
        af = this.features.get(AddressingFeature.class);
    }
    if (af != null && af.isEnabled())
        isAddressingEnabled = true;
    MemberSubmissionAddressingFeature msa = features.get(MemberSubmissionAddressingFeature.class);
    if (msa == null) {
        msa = this.features.get(MemberSubmissionAddressingFeature.class);
    }
    if (msa != null && msa.isEnabled())
        isAddressingEnabled = true;
    if(isAddressingEnabled && wsdlService != null && wsdlService.get(portName) != null) {
        wsepr = wsdlService.get(portName).getEPR();
    }
    return createDispatch(portName, wsepr, jaxbContext, mode, features);
}
 
Example 7
Project: lams   File: JaxWsPortClientInterceptor.java   View source code 6 votes vote down vote up
/**
 * Obtain the port stub from the given JAX-WS Service.
 * @param service the Service object to obtain the port from
 * @param portQName the name of the desired port, if specified
 * @return the corresponding port object as returned from
 * {@code Service.getPort(...)}
 */
protected Object getPortStub(Service service, QName portQName) {
	if (this.portFeatures != null || this.webServiceFeatures != null) {
		WebServiceFeature[] portFeaturesToUse = this.portFeatures;
		if (portFeaturesToUse == null) {
			portFeaturesToUse = new WebServiceFeature[this.webServiceFeatures.length];
			for (int i = 0; i < this.webServiceFeatures.length; i++) {
				portFeaturesToUse[i] = convertWebServiceFeature(this.webServiceFeatures[i]);
			}
		}
		return (portQName != null ? service.getPort(portQName, getServiceInterface(), portFeaturesToUse) :
				service.getPort(getServiceInterface(), portFeaturesToUse));
	}
	else {
		return (portQName != null ? service.getPort(portQName, getServiceInterface()) :
				service.getPort(getServiceInterface()));
	}
}
 
Example 8
Project: OpenJSharp   File: Stubs.java   View source code 6 votes vote down vote up
/**
 * 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());
}
 
Example 9
Project: OpenJSharp   File: Stubs.java   View source code 6 votes vote down vote up
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @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 epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
 
Example 10
Project: openjdk-jdk10   File: Invoker.java   View source code 6 votes vote down vote up
/**
 * Creates a class loader for loading JAXB/WS 2.2 jar
 */
private static URL[] findIstack22APIs(ClassLoader cl) throws ClassNotFoundException, IOException {
    List<URL> urls = new ArrayList<URL>();

    if(Service.class.getClassLoader()==null) {
        // JAX-WS API is loaded from bootstrap class loader
        URL res = cl.getResource("javax/xml/ws/EndpointContext.class");
        if(res==null)
            throw new ClassNotFoundException("There's no JAX-WS 2.2 API in the classpath");
        urls.add(ParallelWorldClassLoader.toJarUrl(res));
        res = cl.getResource("javax/xml/bind/JAXBPermission.class");
        if(res==null)
            throw new ClassNotFoundException("There's no JAXB 2.2 API in the classpath");
        urls.add(ParallelWorldClassLoader.toJarUrl(res));
    }

    return urls.toArray(new URL[urls.size()]);
}
 
Example 11
Project: openjdk-jdk10   File: WSServiceDelegate.java   View source code 6 votes vote down vote up
public <T> Dispatch<T> createDispatch(QName portName, Class<T> aClass, Service.Mode mode, WebServiceFeatureList features) {
    WSEndpointReference wsepr = null;
    boolean isAddressingEnabled = false;
    AddressingFeature af = features.get(AddressingFeature.class);
    if (af == null) {
        af = this.features.get(AddressingFeature.class);
    }
    if (af != null && af.isEnabled())
        isAddressingEnabled = true;
    MemberSubmissionAddressingFeature msa = features.get(MemberSubmissionAddressingFeature.class);
    if (msa == null) {
        msa = this.features.get(MemberSubmissionAddressingFeature.class);
    }
    if (msa != null && msa.isEnabled())
        isAddressingEnabled = true;
    if(isAddressingEnabled && wsdlService != null && wsdlService.get(portName) != null) {
        wsepr = wsdlService.get(portName).getEPR();
    }
    return createDispatch(portName, wsepr, aClass, mode, features);
}
 
Example 12
Project: oscm-app   File: BesDAO.java   View source code 5 votes vote down vote up
<T> T getServicePort(Class<T> serviceClass, Map<String, Setting> settings)
            throws MalformedURLException {

        String targetNamespace = serviceClass.getAnnotation(WebService.class)
                .targetNamespace();
        QName serviceQName = new QName(targetNamespace,
                serviceClass.getSimpleName());

        Service service = createWebService(getWsdlUrl(serviceClass, settings),
                serviceQName);
//        addVersionInformation(service);
        return service.getPort(serviceClass);
    }
 
Example 13
Project: OperatieBRP   File: VerzendingVerwerkPersoonWebServiceClientImpl.java   View source code 5 votes vote down vote up
/**
 * Initialiseert webservice client voor protocolleer synchronisatie persoon.
 */
@PostConstruct
public void initWebServiceClient() {
    webserviceClient = initService().createDispatch(SYNC_PERSOON_PORT_NAME, Source.class, Service.Mode.PAYLOAD);
    /// future calls to getRequestContext() will use a thread local request context, allowing the request context to be threadsafe.
    webserviceClient.getRequestContext().put("thread.local.request.context", Boolean.TRUE.toString().toLowerCase());
}
 
Example 14
Project: oscm-app   File: BesDAOTest.java   View source code 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void getBESWebService_withInstance() throws MalformedURLException,
        APPlatformException {
    // given
    BesDAO besDAO = spy(new BesDAO());
    besDAO.configService = spy(new APPConfigurationServiceBean());
    Map<String, Setting> settings = getSettingsForMode("INTERNAL");
    doReturn(settings).when(besDAO.configService)
            .getAllProxyConfigurationSettings();
    Map<String, Setting> controllerSettings = getControllerSettings(true,
            true, true);
    doReturn(controllerSettings).when(besDAO.configService)
            .getControllerConfigurationSettings(anyString());
    doReturn(mock(Service.class)).when(besDAO).createWebService(
            any(URL.class), any(QName.class));
    doReturn(idServ).when(besDAO).getServicePort(eq(IdentityService.class),
            anyMap());
    doReturn(new PasswordAuthentication("user", "password")).when(
            besDAO.configService).getAuthenticationForAPPAdmin(anyMap());
    ServiceInstance si = new ServiceInstance();

    // when
    besDAO.getBESWebService(IdentityService.class, si, Optional.empty());

    // then
    verify(besDAO.configService, times(1))
            .getAuthenticationForBESTechnologyManager(anyString(), eq(si),
                    anyMap());
}
 
Example 15
Project: oscm   File: ClientVersionHandler.java   View source code 5 votes vote down vote up
/**
 * This method adds a version SOAP Handler into the handler chain of a web
 * service. The version SOAP Handler is responsible to add a version
 * information in the header of the outbound SOAP message.
 * 
 * @param service
 *            set HandlerResolver for service by invoking service
 *            <code>setHandlerResolver</code> method.
 * @return service with handler chain for handling version information.
 */
public Service addVersionInformationToClient(Service service) {
    service.setHandlerResolver(new HandlerResolver() {
        @SuppressWarnings("rawtypes")
        @Override
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            List<Handler> handlerList = new ArrayList<Handler>();
            handlerList.add(new VersionHandler(version));
            return handlerList;
        }
    });
    return service;
}
 
Example 16
Project: oscm   File: WsProxy.java   View source code 5 votes vote down vote up
/**
 * Helper method for creating a web service proxy. The service version
 * information is added into the header of the outbound SOAP message.
 * 
 * @param info
 *            - the properties for accessing the web service
 * @param type
 *            - web service described with the corresponding type
 * @return the web service proxy
 * @throws MalformedURLException
 */
private static <T> T createProxy(WsInfo info, final Class<T> type) {
    Service service = null;
    try {
        service = Service.create(new URL(info.getRemoteBssWsUrl()),
                new QName(NAMESPACE_URI, type.getSimpleName()));
    } catch (MalformedURLException e) {
        String text = "Error:Malformed URL";
        logger.error(text);
    }
    service = addVersionInformation(service);
    return service.getPort(type);
}
 
Example 17
Project: OperatieBRP   File: VerzendingBijhoudingsNotificatieWebServiceClientImpl.java   View source code 5 votes vote down vote up
/**
 * Initialiseert webservice client voor protocolleer bijhoudingsnotificatie..
 */
@PostConstruct
public void initWebServiceClient() {
    webserviceClient = initService().createDispatch(VERWERK_BIJH_PLAN_PORT_NAME, Source.class, Service.Mode.PAYLOAD);
    /// future calls to getRequestContext() will use a thread local request context, allowing the request context to be threadsafe.
    webserviceClient.getRequestContext().put("thread.local.request.context", Boolean.TRUE.toString().toLowerCase());
}
 
Example 18
Project: oscm   File: BesDAO.java   View source code 5 votes vote down vote up
public Service createWebService(URL wsdlUrl, QName serviceQName) {
    return Service.create(wsdlUrl, serviceQName);
}
 
Example 19
Project: oscm   File: ServiceFactory.java   View source code 5 votes vote down vote up
private <T> T getServicePort(Class<T> serviceClass)
        throws ParserConfigurationException {

    String targetNamespace = serviceClass.getAnnotation(WebService.class)
            .targetNamespace();
    QName serviceQName = new QName(targetNamespace,
            serviceClass.getSimpleName());
    Service service = createWebService(localWSDLUrl, serviceQName);
    service = addVersionInformation(service);
    return service.getPort(
            determineEndpointReference(serviceClass.getSimpleName()),
            serviceClass);
}
 
Example 20
Project: lams   File: CommonAnnotationBeanPostProcessor.java   View source code 5 votes vote down vote up
public WebServiceRefElement(Member member, PropertyDescriptor pd) {
	super(member, pd);
	AnnotatedElement ae = (AnnotatedElement) member;
	WebServiceRef resource = ae.getAnnotation(WebServiceRef.class);
	String resourceName = resource.name();
	Class<?> resourceType = resource.type();
	this.isDefaultName = !StringUtils.hasLength(resourceName);
	if (this.isDefaultName) {
		resourceName = this.member.getName();
		if (this.member instanceof Method && resourceName.startsWith("set") && resourceName.length() > 3) {
			resourceName = Introspector.decapitalize(resourceName.substring(3));
		}
	}
	if (resourceType != null && !Object.class.equals(resourceType)) {
		checkResourceType(resourceType);
	}
	else {
		// No resource type specified... check field/method.
		resourceType = getResourceType();
	}
	this.name = resourceName;
	this.elementType = resourceType;
	if (Service.class.isAssignableFrom(resourceType)) {
		this.lookupType = resourceType;
	}
	else {
		this.lookupType = (!Object.class.equals(resource.value()) ? resource.value() : Service.class);
	}
	this.mappedName = resource.mappedName();
	this.wsdlLocation = resource.wsdlLocation();
}
 
Example 21
Project: openjdk-jdk10   File: WSEndpointReference.java   View source code 5 votes vote down vote up
/**
 * Creates a {@link Dispatch} that can be used to talk to this EPR.
 *
 * <p>
 * All the normal WS-Addressing processing happens automatically,
 * such as setting the endpoint address to {@link #getAddress() the address},
 * and sending the reference parameters associated with this EPR as
 * headers, etc.
 */
public @NotNull <T> Dispatch<T> createDispatch(
    @NotNull Service jaxwsService,
    @NotNull Class<T> type,
    @NotNull Service.Mode mode,
    WebServiceFeature... features) {

    // TODO: implement it in a better way
    return jaxwsService.createDispatch(toSpec(),type,mode,features);
}
 
Example 22
Project: OpenJSharp   File: WSEndpointReference.java   View source code 5 votes vote down vote up
/**
 * Creates a {@link Dispatch} that can be used to talk to this EPR.
 *
 * <p>
 * All the normal WS-Addressing processing happens automatically,
 * such as setting the endpoint address to {@link #getAddress() the address},
 * and sending the reference parameters associated with this EPR as
 * headers, etc.
 */
public @NotNull <T> Dispatch<T> createDispatch(
    @NotNull Service jaxwsService,
    @NotNull Class<T> type,
    @NotNull Service.Mode mode,
    WebServiceFeature... features) {

    // TODO: implement it in a better way
    return jaxwsService.createDispatch(toSpec(),type,mode,features);
}
 
Example 23
Project: Lagerta   File: RPCServiceImpl.java   View source code 5 votes vote down vote up
@Override
public <T> T get(Class<T> clazz, String name) {
    QName qName = MAPPING.get(clazz);
    if (qName == null) {
        return null;
    }
    try {
        URL url = new URL(EndpointUtils.formatEndpoint(address, name));
        return Service.create(url, qName).getPort(clazz);
    }
    catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}
 
Example 24
Project: openjdk-jdk10   File: XmlWebServiceRef.java   View source code 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Class<? extends Service> value() {
    if (value == null) {
        return Service.class;
    }
    return (Class<Service>) findClass(value);
}
 
Example 25
Project: openjdk-jdk10   File: DispatchImpl.java   View source code 5 votes vote down vote up
public static void checkValidSOAPMessageDispatch(WSBinding binding, Service.Mode mode) {
    // Dispatch<SOAPMessage> is only valid for soap binding and in Service.Mode.MESSAGE
    if (DispatchImpl.isXMLHttp(binding))
        throw new WebServiceException(DispatchMessages.INVALID_SOAPMESSAGE_DISPATCH_BINDING(HTTPBinding.HTTP_BINDING, SOAPBinding.SOAP11HTTP_BINDING + " or " + SOAPBinding.SOAP12HTTP_BINDING));
    if (DispatchImpl.isPAYLOADMode(mode))
        throw new WebServiceException(DispatchMessages.INVALID_SOAPMESSAGE_DISPATCH_MSGMODE(mode.name(), Service.Mode.MESSAGE.toString()));
}
 
Example 26
Project: OpenJSharp   File: DispatchImpl.java   View source code 5 votes vote down vote up
static void checkNullAllowed(@Nullable Object in, RequestContext rc, WSBinding binding, Service.Mode mode) {

        if (in != null)
            return;

        //With HTTP Binding a null invocation parameter can not be used
        //with HTTP Request Method == POST
        if (isXMLHttp(binding)){
            if (methodNotOk(rc))
                throw new WebServiceException(DispatchMessages.INVALID_NULLARG_XMLHTTP_REQUEST_METHOD(HTTP_REQUEST_METHOD_POST, HTTP_REQUEST_METHOD_GET));
        } else { //soapBinding
              if (mode == Service.Mode.MESSAGE )
                   throw new WebServiceException(DispatchMessages.INVALID_NULLARG_SOAP_MSGMODE(mode.name(), Service.Mode.PAYLOAD.toString()));
        }
    }
 
Example 27
Project: OpenJSharp   File: DispatchImpl.java   View source code 5 votes vote down vote up
public static void checkValidDataSourceDispatch(WSBinding binding, Service.Mode mode) {
    // Dispatch<DataSource> is only valid with xml/http binding and in Service.Mode.MESSAGE
    if (!DispatchImpl.isXMLHttp(binding))
        throw new WebServiceException(DispatchMessages.INVALID_DATASOURCE_DISPATCH_BINDING("SOAP/HTTP", HTTPBinding.HTTP_BINDING));
    if (DispatchImpl.isPAYLOADMode(mode))
        throw new WebServiceException(DispatchMessages.INVALID_DATASOURCE_DISPATCH_MSGMODE(mode.name(), Service.Mode.MESSAGE.toString()));
}
 
Example 28
Project: openjdk-jdk10   File: XMLProviderArgumentBuilder.java   View source code 5 votes vote down vote up
static XMLProviderArgumentBuilder createBuilder(ProviderEndpointModel model, WSBinding binding) {
    if (model.mode == Service.Mode.PAYLOAD) {
        return new PayloadSource();
    } else {
        if(model.datatype==Source.class)
            return new PayloadSource();
        if(model.datatype== DataSource.class)
            return new DataSourceParameter(binding);
        throw new WebServiceException(ServerMessages.PROVIDER_INVALID_PARAMETER_TYPE(model.implClass,model.datatype));
    }
}
 
Example 29
Project: OpenJSharp   File: SOAPProviderArgumentBuilder.java   View source code 5 votes vote down vote up
static ProviderArgumentsBuilder create(ProviderEndpointModel model, SOAPVersion soapVersion) {
    if (model.mode == Service.Mode.PAYLOAD) {
        return new PayloadSource(soapVersion);
    } else {
        if(model.datatype==Source.class)
            return new MessageSource(soapVersion);
        if(model.datatype==SOAPMessage.class)
            return new SOAPMessageParameter(soapVersion);
        if(model.datatype==Message.class)
            return new MessageProviderArgumentBuilder(soapVersion);
        throw new WebServiceException(ServerMessages.PROVIDER_INVALID_PARAMETER_TYPE(model.implClass,model.datatype));
    }
}
 
Example 30
Project: uavstack   File: JaxWSHookIT.java   View source code 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public Dispatch createDispatch(Dispatch d, Service s, Object[] args) {

    Binding binding = ((BindingProvider) d).getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(this.handler);
    binding.setHandlerChain(handlerChain);

    final String wsdlLocation = getServiceURL(s);

    Dispatch tProxy = JDKProxyInvokeUtil.newProxyInstance(this.getClass().getClassLoader(),
            new Class[] { Dispatch.class },
            new JDKProxyInvokeHandler<Dispatch>(d, new DispatchProcessor(wsdlLocation.toString(), this.handler)));
    return tProxy;
}
 
Example 31
Project: openjdk-jdk10   File: Test.java   View source code 5 votes vote down vote up
public static void main(String[] args) throws IOException, TransformerException {

        try {
            String address = deployWebservice();
            Service service = Service.create(new URL(address), ServiceImpl.SERVICE_NAME);

            Dispatch<Source> d = service.createDispatch(ServiceImpl.PORT_NAME, Source.class, Service.Mode.MESSAGE);
            Source response = d.invoke(new StreamSource(new StringReader(XML_REQUEST)));

            String resultXml = toString(response);

            log("= request ======== \n");
            log(XML_REQUEST);
            log("= result ========= \n");
            log(resultXml);
            log("\n==================");

            boolean xsAnyMixedPartSame = resultXml.contains(XS_ANY_MIXED_PART);
            log("resultXml.contains(XS_ANY_PART) = " + xsAnyMixedPartSame);
            if (!xsAnyMixedPartSame) {
                fail("The xs:any content=mixed part is supposed to be same in request and response.");
                throw new RuntimeException();
            }

            log("TEST PASSED");
        } finally {
            stopWebservice();

            // if you need to debug or explore wsdl generation result
            // comment this line out:
            deleteGeneratedFiles();
        }
    }
 
Example 32
Project: OperatieBRP   File: VerzendingVerwerkVrijBerichtWebServiceClientImpl.java   View source code 5 votes vote down vote up
/**
 * Initialiseert ws client voor vrij bericht.
 */
@PostConstruct
public void initWebServiceClient() {
    webserviceClient = initService().createDispatch(VRIJBERICHT_PORT_NAME, Source.class, Service.Mode.PAYLOAD);
    // future calls to getRequestContext() will use a thread local request context, allowing the request context to be threadsafe.
    webserviceClient.getRequestContext().put("thread.local.request.context", Boolean.TRUE.toString().toLowerCase());
}
 
Example 33
Project: uavstack   File: JaxWSHookIT.java   View source code 5 votes vote down vote up
/**
 * this is for Client Stub Programming
 * 
 * @param t
 * @param s
 * @param args
 * @return
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T getPort(T t, Service s, Object[] args) {

    Class<T> clz = null;
    if (Class.class.isAssignableFrom(args[0].getClass())) {
        clz = (Class<T>) args[0];
    }
    else if (Class.class.isAssignableFrom(args[1].getClass())) {
        clz = (Class<T>) args[1];
    }

    if (clz == null) {
        return t;
    }

    Binding binding = ((BindingProvider) t).getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(this.handler);
    binding.setHandlerChain(handlerChain);

    final String wsdlLocation = getServiceURL(s);

    T tProxy = JDKProxyInvokeUtil.newProxyInstance(clz.getClassLoader(), new Class[] { clz },
            new JDKProxyInvokeHandler<T>(t, new ClientStubProcessor(wsdlLocation.toString(), this.handler)));
    return tProxy;
}
 
Example 34
Project: oscm-app   File: BesDAO.java   View source code 4 votes vote down vote up
public Service createWebService(URL wsdlUrl, QName serviceQName) {
    return Service.create(wsdlUrl, serviceQName);
}
 
Example 35
Project: openjdk-jdk10   File: WSServiceDelegate.java   View source code 4 votes vote down vote up
@Override
public <T> Dispatch<T> createDispatch(QName portName, WSEndpointReference wsepr, Class<T> aClass, Service.Mode mode, WebServiceFeature... features) {
    return createDispatch(portName, wsepr, aClass, mode, new WebServiceFeatureList(features));
}
 
Example 36
Project: openjdk-jdk10   File: WSServiceDelegate.java   View source code 4 votes vote down vote up
public Dispatch<Object> createDispatch(QName portName, JAXBContext jaxbContext, Service.Mode mode) throws WebServiceException {
    return createDispatch(portName, jaxbContext, mode, EMPTY_FEATURES);
}
 
Example 37
Project: oscm   File: BSSWebServiceFactory.java   View source code 4 votes vote down vote up
/**
 * Creates a OSCM Web service with the given parameters.
 * 
 * @param serviceClass
 *            the class of the Web service to be created
 * @param authentication
 *            a <code>PasswordAuthentication</code> object specifying the
 *            credentials to be used for authentication
 * @return the service class
 * @throws ConfigurationException
 *             if the configuration of the platform is incorrect
 * @throws MalformedURLException
 *             if the base URL of the OSCM configuration is malformed
 */
public static <T> T getBSSWebService(Class<T> serviceClass,
        PasswordAuthentication authentication)
        throws ConfigurationException, MalformedURLException {

    String targetNamespace = serviceClass.getAnnotation(WebService.class)
            .targetNamespace();
    QName serviceQName = new QName(targetNamespace,
            serviceClass.getSimpleName());

    String wsdlUrl = APPlatformServiceFactory.getInstance()
            .getBSSWebServiceWSDLUrl();
    wsdlUrl = wsdlUrl.replace("{SERVICE}", serviceClass.getSimpleName());
    String serviceUrl = APPlatformServiceFactory.getInstance()
    .getBSSWebServiceUrl();
    serviceUrl=serviceUrl.replace("{SERVICE}", serviceClass.getSimpleName());
    Service service = Service.create(new URL(wsdlUrl), serviceQName);

    boolean isSsoMode = wsdlUrl != null
            && wsdlUrl.toLowerCase().endsWith("/sts?wsdl");
    String portSuffix = isSsoMode ? "PortSTS" : "PortBASIC";

    T client = service.getPort(
            new QName(targetNamespace, serviceClass.getSimpleName()
                    + portSuffix), serviceClass);

    String usernameConstant = isSsoMode ? "username"
            : BindingProvider.USERNAME_PROPERTY;
    String passwordConstant = isSsoMode ? "password"
            : BindingProvider.PASSWORD_PROPERTY;

    Map<String, Object> clientRequestContext = ((BindingProvider) client)
            .getRequestContext();
    clientRequestContext
            .put(usernameConstant, authentication.getUserName());
    clientRequestContext
            .put(passwordConstant, authentication.getPassword());
    clientRequestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
            serviceUrl );
    return client;
}
 
Example 38
Project: openjdk-jdk10   File: SOAPMessageDispatch.java   View source code 4 votes vote down vote up
public SOAPMessageDispatch(WSPortInfo portInfo, Service.Mode mode, BindingImpl binding, WSEndpointReference epr) {
    super(portInfo, mode, binding, epr);
}
 
Example 39
Project: openjdk-jdk10   File: WSServiceDelegate.java   View source code 4 votes vote down vote up
public WSServiceDelegate(URL wsdlDocumentLocation, QName serviceName, Class<? extends Service> serviceClass, WebServiceFeature... features) {
    this(wsdlDocumentLocation, serviceName, serviceClass, new WebServiceFeatureList(features));
}
 
Example 40
Project: oscm   File: WSPortConnector.java   View source code 4 votes vote down vote up
/**
 * Reads the WSDL and determines the target namespace.
 * 
 * @param locator
 *            The URL of the WSDL.
 * @param host
 *            optional the host to be used when the one from the wsdl must
 *            not be used
 * @return The service's target namespace.
 * @throws WSDLException
 *             Thrown in case the WSDL could not be evaluated.
 */
private WSPortDescription getServiceDetails(WSDLLocator locator, String host)
        throws WSDLException {
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();

    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    Definition serviceDefinition = wsdlReader.readWSDL(locator);
    String tns = serviceDefinition.getTargetNamespace();
    // read the port name
    String endpointURL = null;
    final Map<?, ?> services = serviceDefinition.getServices();
    if (services != null) {
        for (Object serviceValue : services.values()) {
            javax.wsdl.Service service = (javax.wsdl.Service) serviceValue;
            Map<?, ?> ports = service.getPorts();
            if (ports != null) {
                for (Object portValue : ports.values()) {
                    Port port = (Port) portValue;
                    List<?> extensibilityElements = port
                            .getExtensibilityElements();
                    for (Object ex : extensibilityElements) {
                        ExtensibilityElement ext = (ExtensibilityElement) ex;
                        if (ext instanceof SOAPAddress) {
                            SOAPAddress address = (SOAPAddress) ext;
                            endpointURL = address.getLocationURI();
                            if (host != null) {
                                int idx = endpointURL.indexOf("//") + 2;
                                String tmp = endpointURL.substring(0, idx)
                                        + host
                                        + endpointURL.substring(endpointURL
                                                .indexOf(':', idx));
                                endpointURL = tmp;
                            }
                        }
                    }
                }
            }
        }
    }

    WSPortDescription result = new WSPortDescription();
    result.setTargetNamespace(tns);
    result.setEndpointURL(endpointURL);
    Element versionElement = serviceDefinition.getDocumentationElement();
    if (versionElement != null) {
        result.setVersion(versionElement.getTextContent());
    }
    return result;
}