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);
}
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 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, new Integer(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 ReflectionServiceFactoryTest method testWrappedBuild.
@Test
public void testWrappedBuild() throws Exception {
Service service = createService(true);
ServiceInfo si = service.getServiceInfos().get(0);
InterfaceInfo intf = si.getInterface();
assertEquals(4, intf.getOperations().size());
String ns = si.getName().getNamespaceURI();
OperationInfo sayHelloOp = intf.getOperation(new QName(ns, "sayHello"));
assertNotNull(sayHelloOp);
assertEquals("sayHello", sayHelloOp.getInput().getName().getLocalPart());
List<MessagePartInfo> messageParts = sayHelloOp.getInput().getMessageParts();
assertEquals(1, messageParts.size());
assertNotNull(messageParts.get(0).getXmlSchema());
// test unwrapping
assertTrue(sayHelloOp.isUnwrappedCapable());
OperationInfo unwrappedOp = sayHelloOp.getUnwrappedOperation();
assertEquals("sayHello", unwrappedOp.getInput().getName().getLocalPart());
messageParts = unwrappedOp.getInput().getMessageParts();
assertEquals(0, messageParts.size());
// test output
messageParts = sayHelloOp.getOutput().getMessageParts();
assertEquals(1, messageParts.size());
assertEquals("sayHelloResponse", sayHelloOp.getOutput().getName().getLocalPart());
messageParts = unwrappedOp.getOutput().getMessageParts();
assertEquals("sayHelloResponse", unwrappedOp.getOutput().getName().getLocalPart());
assertEquals(1, messageParts.size());
MessagePartInfo mpi = messageParts.get(0);
assertEquals("return", mpi.getName().getLocalPart());
assertEquals(String.class, mpi.getTypeClass());
}
use of org.apache.cxf.service.model.MessagePartInfo in project cxf by apache.
the class ServiceJavascriptBuilder method createResponseDeserializer.
// This ignores 'wrapped', because it assumes one part that we can use one way or
// the other. For simple cases, this is certainly OK.
private void createResponseDeserializer(MessageInfo outputMessage) {
List<MessagePartInfo> parts = outputMessage.getMessageParts();
if (parts.size() != 1) {
unsupportedConstruct("MULTIPLE_OUTPUTS", outputMessage.getName().toString());
}
List<ParticleInfo> elements = new ArrayList<>();
String functionName = outputDeserializerFunctionName(outputMessage);
code.append("function " + functionName + "(cxfjsutils, partElement) {\n");
getElementsForParts(outputMessage, elements);
ParticleInfo element = elements.get(0);
XmlSchemaType type = null;
if (isRPC) {
utils.appendLine("cxfjsutils.trace('rpc element: ' + cxfjsutils.traceElementName(partElement));");
utils.appendLine("partElement = cxfjsutils.getFirstElementChild(partElement);");
utils.appendLine("cxfjsutils.trace('rpc element: ' + cxfjsutils.traceElementName(partElement));");
}
type = element.getType();
if (!element.isEmpty()) {
if (type instanceof XmlSchemaComplexType) {
String typeObjectName = nameManager.getJavascriptName(element.getControllingName());
utils.appendLine("var returnObject = " + typeObjectName + "_deserialize (cxfjsutils, partElement);\n");
utils.appendLine("return returnObject;");
} else if (type instanceof XmlSchemaSimpleType) {
XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) type;
utils.appendLine("var returnText = cxfjsutils.getNodeText(partElement);");
utils.appendLine("var returnObject = " + utils.javascriptParseExpression(simpleType, "returnText") + ";");
utils.appendLine("return returnObject;");
} else if (type != null) {
utils.appendLine("// Unsupported construct " + type.getClass());
} else {
utils.appendLine("// No type for element " + element.getXmlName());
}
}
code.append("}\n");
}
Aggregations