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;
}
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);
}
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();
}
Aggregations