use of org.apache.cxf.service.model.MessagePartInfo in project cxf by apache.
the class ComplexClient method main.
/**
* @param args
*/
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.out.println("please specify wsdl");
System.exit(1);
}
URL wsdlURL;
File wsdlFile = new File(args[0]);
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(args[0]);
}
System.out.println(wsdlURL);
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
Client client = factory.createClient(wsdlURL.toExternalForm(), SERVICE_NAME);
ClientImpl clientImpl = (ClientImpl) client;
Endpoint endpoint = clientImpl.getEndpoint();
ServiceInfo serviceInfo = endpoint.getService().getServiceInfos().get(0);
QName bindingName = new QName("http://Company.com/Application", "Company_ESB_Application_Biztalk_AgentDetails_4405_AgentDetails_PrtSoap");
BindingInfo binding = serviceInfo.getBinding(bindingName);
// {
QName opName = new QName("http://Company.com/Application", "GetAgentDetails");
BindingOperationInfo boi = binding.getOperation(opName);
BindingMessageInfo inputMessageInfo = boi.getInput();
List<MessagePartInfo> parts = inputMessageInfo.getMessageParts();
// only one part.
MessagePartInfo partInfo = parts.get(0);
Class<?> partClass = partInfo.getTypeClass();
// GetAgentDetails
System.out.println(partClass.getCanonicalName());
Object inputObject = partClass.newInstance();
// Unfortunately, the slot inside of the part object is also called 'part'.
// this is the descriptor for get/set part inside the GetAgentDetails class.
PropertyDescriptor partPropertyDescriptor = new PropertyDescriptor("part", partClass);
// This is the type of the class which really contains all the parameter information.
// AgentWSRequest
Class<?> partPropType = partPropertyDescriptor.getPropertyType();
System.out.println(partPropType.getCanonicalName());
Object inputPartObject = partPropType.newInstance();
partPropertyDescriptor.getWriteMethod().invoke(inputObject, inputPartObject);
PropertyDescriptor numberPropertyDescriptor = new PropertyDescriptor("agentNumber", partPropType);
numberPropertyDescriptor.getWriteMethod().invoke(inputPartObject, Integer.valueOf(314159));
Object[] result = client.invoke(opName, inputObject);
Class<?> resultClass = result[0].getClass();
// GetAgentDetailsResponse
System.out.println(resultClass.getCanonicalName());
PropertyDescriptor resultDescriptor = new PropertyDescriptor("agentWSResponse", resultClass);
Object wsResponse = resultDescriptor.getReadMethod().invoke(result[0]);
Class<?> wsResponseClass = wsResponse.getClass();
System.out.println(wsResponseClass.getCanonicalName());
PropertyDescriptor agentNameDescriptor = new PropertyDescriptor("agentName", wsResponseClass);
String agentName = (String) agentNameDescriptor.getReadMethod().invoke(wsResponse);
System.out.println("Agent name: " + agentName);
}
use of org.apache.cxf.service.model.MessagePartInfo in project cxf by apache.
the class CorbaStreamFaultInInterceptor method getFaultInfo.
protected FaultInfo getFaultInfo(OperationInfo opInfo, QName faultName) {
Iterator<FaultInfo> faults = opInfo.getFaults().iterator();
while (faults.hasNext()) {
FaultInfo fault = faults.next();
MessagePartInfo partInfo = fault.getMessageParts().get(0);
if (partInfo.isElement() && partInfo.getElementQName().getLocalPart().equals(faultName.getLocalPart())) {
return fault;
} else if (partInfo.getTypeQName().getLocalPart().equals(faultName.getLocalPart())) {
return fault;
}
}
return null;
}
use of org.apache.cxf.service.model.MessagePartInfo in project cxf by apache.
the class CorbaStreamFaultInInterceptor method createFaultDetail.
private void createFaultDetail(Document faultData, FaultInfo faultInfo, Fault faultEx) {
MessagePartInfo partInfo = faultInfo.getMessageParts().get(0);
QName partInfoName = partInfo.getElementQName();
Document faultDoc = DOMUtils.getEmptyDocument();
Element faultElement = faultDoc.createElement("detail");
Element partElement = faultDoc.createElementNS(partInfoName.getNamespaceURI(), partInfoName.getLocalPart());
Element faultDataElement = (Element) faultData.getFirstChild();
Node node = faultDataElement.getFirstChild();
while (node != null) {
Node importedFaultData = faultDoc.importNode(node, true);
partElement.appendChild(importedFaultData);
node = node.getNextSibling();
}
faultElement.appendChild(partElement);
faultEx.setDetail(faultElement);
}
use of org.apache.cxf.service.model.MessagePartInfo in project cxf by apache.
the class CorbaStreamInInterceptor method getMessageParamQName.
protected QName getMessageParamQName(MessageInfo msgInfo, String paramName, int index) {
QName paramQName = null;
MessagePartInfo part = msgInfo.getMessageParts().get(index);
if (part != null && part.isElement()) {
paramQName = part.getElementQName();
} else if (part != null) {
paramQName = part.getName();
}
return paramQName;
}
use of org.apache.cxf.service.model.MessagePartInfo in project cxf by apache.
the class CorbaStreamFaultOutInterceptor method setUserExceptionFromFaultDetail.
protected void setUserExceptionFromFaultDetail(CorbaMessage message, org.w3c.dom.Element faultDetail, RaisesType exType, OperationInfo opInfo, DataWriter<XMLStreamWriter> writer, ServiceInfo service) throws Exception {
QName exIdlType = exType.getException();
QName elName = new QName("", exIdlType.getLocalPart());
MessagePartInfo faultPart = getFaultMessagePartInfo(opInfo, elName);
// faultDetailt.getFirstChild() skips the "detail" element
Object fault = extractPartsInfoFromDetail((Element) faultDetail.getFirstChild(), exType);
CorbaFaultStreamWriter faultWriter = new CorbaFaultStreamWriter(orb, exType, message.getCorbaTypeMap(), service);
writer.write(fault, faultPart, faultWriter);
CorbaObjectHandler[] objs = faultWriter.getCorbaObjects();
CorbaStreamable streamable = message.createStreamableObject(objs[0], elName);
message.setStreamableException(streamable);
}
Aggregations