Search in sources :

Example 56 with MessagePartInfo

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);
}
Also used : CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) CorbaFaultStreamWriter(org.apache.cxf.binding.corba.runtime.CorbaFaultStreamWriter) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 57 with MessagePartInfo

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;
}
Also used : QName(javax.xml.namespace.QName) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 58 with MessagePartInfo

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);
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) PropertyDescriptor(java.beans.PropertyDescriptor) QName(javax.xml.namespace.QName) ClientImpl(org.apache.cxf.endpoint.ClientImpl) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) URL(java.net.URL) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) Client(org.apache.cxf.endpoint.Client) File(java.io.File)

Example 59 with MessagePartInfo

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());
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) Test(org.junit.Test)

Example 60 with MessagePartInfo

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");
}
Also used : XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) ParticleInfo(org.apache.cxf.javascript.ParticleInfo) ArrayList(java.util.ArrayList) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Aggregations

MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)157 QName (javax.xml.namespace.QName)97 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)60 OperationInfo (org.apache.cxf.service.model.OperationInfo)44 Test (org.junit.Test)38 MessageInfo (org.apache.cxf.service.model.MessageInfo)36 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)27 Service (org.apache.cxf.service.Service)21 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)21 Fault (org.apache.cxf.interceptor.Fault)20 BindingInfo (org.apache.cxf.service.model.BindingInfo)20 ArrayList (java.util.ArrayList)18 Endpoint (org.apache.cxf.endpoint.Endpoint)18 MessageContentsList (org.apache.cxf.message.MessageContentsList)18 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)16 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)15 XMLStreamReader (javax.xml.stream.XMLStreamReader)13 Exchange (org.apache.cxf.message.Exchange)13 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)12 FaultInfo (org.apache.cxf.service.model.FaultInfo)11