Search in sources :

Example 1 with ObjectFactory

use of org.apache.cxf.ws.discovery.wsdl.ObjectFactory in project cxf by apache.

the class WSDiscoveryClient method probe.

public ProbeMatchesType probe(ProbeType params, int timeout) {
    Dispatch<Object> disp = this.getDispatchInternal(false, version.getProbeAction());
    if (adHoc) {
        disp.getRequestContext().put("udp.multi.response.timeout", timeout);
        final ProbeMatchesType response = new ProbeMatchesType();
        AsyncHandler<Object> handler = new AsyncHandler<Object>() {

            public void handleResponse(Response<Object> res) {
                try {
                    Object o = res.get();
                    while (o instanceof JAXBElement) {
                        o = ((JAXBElement) o).getValue();
                    }
                    if (o instanceof ProbeMatchesType) {
                        response.getProbeMatch().addAll(((ProbeMatchesType) o).getProbeMatch());
                    } else if (o instanceof HelloType) {
                        HelloType h = (HelloType) o;
                        QName sn = version.getServiceName();
                        if (h.getTypes().contains(sn) || h.getTypes().contains(new QName("", sn.getLocalPart()))) {
                            // A DiscoveryProxy wants us to flip to managed mode
                            uncache();
                            resetDispatch(h.getXAddrs().get(0));
                        }
                    }
                } catch (InterruptedException e) {
                // ?
                } catch (ExecutionException e) {
                // ?
                }
            }
        };
        disp.invokeAsync(new ObjectFactory().createProbe(params), handler);
        return response;
    }
    Object o = disp.invoke(new ObjectFactory().createProbe(params));
    while (o instanceof JAXBElement) {
        o = ((JAXBElement) o).getValue();
    }
    return (ProbeMatchesType) o;
}
Also used : Response(javax.xml.ws.Response) AsyncHandler(javax.xml.ws.AsyncHandler) ObjectFactory(org.apache.cxf.ws.discovery.wsdl.ObjectFactory) QName(javax.xml.namespace.QName) HelloType(org.apache.cxf.ws.discovery.wsdl.HelloType) ProbeMatchesType(org.apache.cxf.ws.discovery.wsdl.ProbeMatchesType) JAXBElement(javax.xml.bind.JAXBElement) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with ObjectFactory

use of org.apache.cxf.ws.discovery.wsdl.ObjectFactory in project cxf by apache.

the class WSDiscoveryClient method addAddressing.

private void addAddressing(BindingProvider p, boolean addSeq, String action) {
    AddressingProperties addrProperties = new AddressingProperties();
    if (action != null) {
        AttributedURIType act = new AttributedURIType();
        act.setValue(action);
        addrProperties.setAction(act);
    }
    if (adHoc) {
        EndpointReferenceType to = new EndpointReferenceType();
        addrProperties.exposeAs(version.getAddressingNamespace());
        AttributedURIType epr = new AttributedURIType();
        epr.setValue(version.getToAddress());
        to.setAddress(epr);
        addrProperties.setTo(to);
        if (addSeq) {
            AppSequenceType s = new AppSequenceType();
            s.setInstanceId(instanceId);
            s.setMessageNumber(msgId.getAndIncrement());
            JAXBElement<AppSequenceType> seq = new ObjectFactory().createAppSequence(s);
            Header h = new Header(seq.getName(), seq, new JAXBDataBinding(getJAXBContext()));
            List<Header> headers = new ArrayList<>();
            headers.add(h);
            p.getRequestContext().put(Header.HEADER_LIST, headers);
        }
    } else {
        addrProperties.exposeAs(version.getAddressingNamespace());
    }
    p.getRequestContext().put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProperties);
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) ObjectFactory(org.apache.cxf.ws.discovery.wsdl.ObjectFactory) Header(org.apache.cxf.headers.Header) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) ArrayList(java.util.ArrayList) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) AppSequenceType(org.apache.cxf.ws.discovery.wsdl.AppSequenceType)

Example 3 with ObjectFactory

use of org.apache.cxf.ws.discovery.wsdl.ObjectFactory in project cxf by apache.

the class WSDiscoveryClient method resolve.

public ResolveMatchType resolve(W3CEndpointReference ref, int timeout) {
    Dispatch<Object> disp = this.getDispatchInternal(false, version.getResolveAction());
    ResolveType rt = new ResolveType();
    rt.setEndpointReference(ref);
    if (adHoc) {
        disp.getRequestContext().put("udp.multi.response.timeout", timeout);
        final Holder<ResolveMatchesType> response = new Holder<ResolveMatchesType>();
        AsyncHandler<Object> handler = new AsyncHandler<Object>() {

            public void handleResponse(Response<Object> res) {
                try {
                    Object o = res.get();
                    while (o instanceof JAXBElement) {
                        o = ((JAXBElement) o).getValue();
                    }
                    if (o instanceof ResolveMatchesType) {
                        response.value = (ResolveMatchesType) o;
                    } else if (o instanceof HelloType) {
                        HelloType h = (HelloType) o;
                        QName sn = version.getServiceName();
                        if (h.getTypes().contains(sn) || h.getTypes().contains(new QName("", sn.getLocalPart()))) {
                            // A DiscoveryProxy wants us to flip to managed mode
                            uncache();
                            resetDispatch(h.getXAddrs().get(0));
                        }
                    }
                } catch (InterruptedException e) {
                // ?
                } catch (ExecutionException e) {
                // ?
                }
            }
        };
        disp.invokeAsync(new ObjectFactory().createResolve(rt), handler);
        return response.value == null ? null : response.value.getResolveMatch();
    }
    Object o = disp.invoke(new ObjectFactory().createResolve(rt));
    while (o instanceof JAXBElement) {
        o = ((JAXBElement) o).getValue();
    }
    return o == null ? null : ((ResolveMatchesType) o).getResolveMatch();
}
Also used : AsyncHandler(javax.xml.ws.AsyncHandler) ResolveMatchesType(org.apache.cxf.ws.discovery.wsdl.ResolveMatchesType) QName(javax.xml.namespace.QName) Holder(javax.xml.ws.Holder) ResolveType(org.apache.cxf.ws.discovery.wsdl.ResolveType) HelloType(org.apache.cxf.ws.discovery.wsdl.HelloType) JAXBElement(javax.xml.bind.JAXBElement) Response(javax.xml.ws.Response) ObjectFactory(org.apache.cxf.ws.discovery.wsdl.ObjectFactory) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ObjectFactory (org.apache.cxf.ws.discovery.wsdl.ObjectFactory)3 ExecutionException (java.util.concurrent.ExecutionException)2 JAXBElement (javax.xml.bind.JAXBElement)2 QName (javax.xml.namespace.QName)2 AsyncHandler (javax.xml.ws.AsyncHandler)2 Response (javax.xml.ws.Response)2 HelloType (org.apache.cxf.ws.discovery.wsdl.HelloType)2 ArrayList (java.util.ArrayList)1 Holder (javax.xml.ws.Holder)1 Header (org.apache.cxf.headers.Header)1 JAXBDataBinding (org.apache.cxf.jaxb.JAXBDataBinding)1 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)1 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)1 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)1 AppSequenceType (org.apache.cxf.ws.discovery.wsdl.AppSequenceType)1 ProbeMatchesType (org.apache.cxf.ws.discovery.wsdl.ProbeMatchesType)1 ResolveMatchesType (org.apache.cxf.ws.discovery.wsdl.ResolveMatchesType)1 ResolveType (org.apache.cxf.ws.discovery.wsdl.ResolveType)1