use of org.apache.cxf.jaxws.support.JaxWsClientEndpointImpl in project cxf by apache.
the class DispatchImpl method calculateOpName.
@SuppressWarnings("unchecked")
private QName calculateOpName(Holder<T> holder, QName opName, boolean hasOpName) throws XMLStreamException {
boolean findDispatchOp = Boolean.TRUE.equals(getRequestContext().get("find.dispatch.operation"));
// if the addressing feature is enabled, set findDispatchOp to true
if (!findDispatchOp) {
// the feature list to be searched is the endpoint and the bus's lists
List<Feature> endpointFeatures = ((JaxWsClientEndpointImpl) client.getEndpoint()).getFeatures();
List<Feature> allFeatures;
if (client.getBus().getFeatures() != null) {
allFeatures = new ArrayList<>(endpointFeatures.size() + client.getBus().getFeatures().size());
allFeatures.addAll(endpointFeatures);
allFeatures.addAll(client.getBus().getFeatures());
} else {
allFeatures = endpointFeatures;
}
for (Feature feature : allFeatures) {
if (feature instanceof WSAddressingFeature) {
findDispatchOp = true;
}
}
}
Source createdSource = null;
Map<String, QName> payloadOPMap = createPayloadEleOpNameMap(client.getEndpoint().getBinding().getBindingInfo(), hasOpName);
if (findDispatchOp && !payloadOPMap.isEmpty()) {
QName payloadElementName = null;
if (holder.value instanceof javax.xml.transform.Source) {
XMLStreamReader reader = null;
try {
reader = StaxUtils.createXMLStreamReader((javax.xml.transform.Source) holder.value);
Document document = StaxUtils.read(reader);
createdSource = new StaxSource(StaxUtils.createXMLStreamReader(document));
payloadElementName = getPayloadElementName(document.getDocumentElement());
} catch (Exception e) {
// ignore, we are trying to get the operation name
} finally {
StaxUtils.close(reader);
}
}
if (holder.value instanceof SOAPMessage) {
payloadElementName = getPayloadElementName((SOAPMessage) holder.value);
}
if (this.context != null) {
payloadElementName = getPayloadElementName(holder.value);
}
if (payloadElementName != null) {
if (hasOpName) {
// Verify the payload element against the given operation name.
// This allows graceful handling of non-standard WSDL definitions
// where different operations have the same payload element.
QName expectedElementName = payloadOPMap.get(opName.toString());
if (expectedElementName == null || !expectedElementName.toString().equals(payloadElementName.toString())) {
// Verification of the provided operation name failed.
// Resolve the operation name from the payload element.
hasOpName = false;
payloadOPMap = createPayloadEleOpNameMap(client.getEndpoint().getBinding().getBindingInfo(), hasOpName);
}
}
QName dispatchedOpName = null;
if (!hasOpName) {
dispatchedOpName = payloadOPMap.get(payloadElementName.toString());
}
if (null != dispatchedOpName) {
BindingOperationInfo dbop = client.getEndpoint().getBinding().getBindingInfo().getOperation(dispatchedOpName);
if (dbop != null) {
opName = dispatchedOpName;
}
}
}
}
if (createdSource != null) {
holder.value = (T) createdSource;
}
return opName;
}
use of org.apache.cxf.jaxws.support.JaxWsClientEndpointImpl in project cxf by apache.
the class ServiceImpl method getJaxwsEndpoint.
private JaxWsClientEndpointImpl getJaxwsEndpoint(QName portName, AbstractServiceFactoryBean sf, WebServiceFeature... features) {
Service service = sf.getService();
EndpointInfo ei = null;
if (portName == null) {
ei = service.getServiceInfos().get(0).getEndpoints().iterator().next();
} else {
ei = service.getEndpointInfo(portName);
if (ei == null) {
PortInfoImpl portInfo = getPortInfo(portName);
if (null != portInfo) {
try {
ei = createEndpointInfo(sf, portName, portInfo);
} catch (BusException e) {
throw new WebServiceException(e);
}
}
}
}
if (ei == null) {
Message msg = new Message("INVALID_PORT", BUNDLE, portName);
throw new WebServiceException(msg.toString());
}
// When the dispatch is created from EPR, the EPR's address will be set in portInfo
PortInfoImpl portInfo = getPortInfo(portName);
if (portInfo != null && portInfo.getAddress() != null && !portInfo.getAddress().equals(ei.getAddress())) {
ei.setAddress(portInfo.getAddress());
}
try {
return new JaxWsClientEndpointImpl(bus, service, ei, this, getAllFeatures(features));
} catch (EndpointException e) {
throw new WebServiceException(e);
}
}
Aggregations