Hi,
There is a CXF sample project (wsdl_first_dynamic_client) that
illustrates how this basically works, but it doesn't seem to work out
of the box and I needed to adjust a few things. I can clean up this
sample code sometime.

For your case, without seeing how you are actually filling the message
and how your entire wsdl looks like, it's difficult to tell what is
wrong.

To illustrate how your case can be done, I made a small example using
a schema similar to yours.

<wsdl:definitions targetNamespace="http://cxf.apache.org/alert_world_soap_http";
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
    xmlns:tns="http://cxf.apache.org/alert_world_soap_http";...>
    <wsdl:types>
        <schema targetNamespace="http://cxf.apache.org/alert_world_soap_http";
            xmlns="http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified">
            <complexType name="getAlertDataRequest">
              <sequence>
                <element name="user" type="string"/>
              </sequence>
            </complexType>
            <complexType name="getAlertDataResponse">
              <sequence>
                <element name="user" type="string"/>
              </sequence>
            </complexType>
            <element name="getAlertDataRequest" type="tns:getAlertDataRequest"/>
            <element name="getAlertDataResponse"
type="tns:getAlertDataResponse"/>
        </schema>
    </wsdl:types>

    <wsdl:message name="getAlertDataRequest">
        <wsdl:part element="tns:getAlertDataRequest" name="in"/>
    </wsdl:message>
    <wsdl:message name="getAlertDataResponse">
        <wsdl:part element="tns:getAlertDataResponse" name="out"/>
    </wsdl:message>

    <wsdl:portType name="Alert">
        <wsdl:operation name="getAlert">
            <wsdl:input message="tns:getAlertDataRequest"
name="getAlertDataRequest"/>
            <wsdl:output message="tns:getAlertDataResponse"
name="getAlertDataResponse"/>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="Alert" type="tns:Alert">
        <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>

        <wsdl:operation name="getAlert">
            <soap:operation soapAction="" style="document"/>
            <wsdl:input name="getAlertDataRequest">
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="getAlertDataResponse">
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>

    </wsdl:binding>
   ..

and then you can fill the message content in the following way:

    JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
    ClientImpl client = (ClientImpl)dcf.createClient("wsdl/alert_world.wsdl");

    QName opName = new
QName("http://cxf.apache.org/alert_world_soap_http";, "getAlert");
    BindingOperationInfo boi =
client.getEndpoint().getEndpointInfo().getBinding().getOperation(opName);
    BindingMessageInfo inputMessageInfo = boi.getInput();
    List<MessagePartInfo> parts = inputMessageInfo.getMessageParts();

    MessagePartInfo partInfo = parts.get(0);
    Class<?> partClass = partInfo.getTypeClass();
    System.out.println("getAlert.type: " + partClass.getCanonicalName());
    Object inputObject = partClass.newInstance();
    PropertyDescriptor partPropertyDescriptor = new
PropertyDescriptor("user", partClass);
    partPropertyDescriptor.getWriteMethod().invoke(inputObject, "Anne");

    System.out.println("Invoking alert...");
    Object[] result = client.invoke(opName, inputObject);

and this will get you the following SOAP message:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
  <soap:Body>
    <getAlertDataRequest xmlns="http://cxf.apache.org/alert_world_soap_http";>
       <user>Anne</user>
    </getAlertDataRequest>
 </soap:Body>
</soap:Envelope>

regards, aki

2011/4/28 srinivas thallapalli <[email protected]>:
> Hi Dan,Aki
>
> Thanks for your reply.
>
> I tried with JaxWsDynamicClientFactory also but still same problem. The
> request soap message contains
>
> <ns2:getAlertDataRequest xmlns:ns2="http://ws.alerts.sbm.savvion.com/";
>  xmlns:xs="http://www.w3.org/2001/XMLSchema";
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:type="xs:string">
>  ebms
> </ns2:getAlertDataRequest>
>
> <user> </user> tag is missing. The following is the corresponding wsdl part
> for getAlertDataRequest
>
> <xs:complexType name="getAlertDataRequest">
>   <xs:sequence>
>       <xs:element name="user" type="xs:string"/>
>    </xs:sequence>
> </xs:complexType>
>
> --
> View this message in context: 
> http://cxf.547215.n5.nabble.com/Problem-with-CXF-tp4341066p4345810.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>

Reply via email to