axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pantvaidya, Vishwajit" <vpant...@selectica.com>
Subject RE: [Axis2] WstxParsingException: Expected a text token, got START_ELEMENT - while passing array from Axis2 client to Axis2 service
Date Fri, 28 Mar 2008 18:50:20 GMT
I was able to get this working - it seems that I do not need any special handling for array
parameters i.e. for string array parameters, all I need to do is to add the individual array
elements to the payload, one by one.


- Vish.
________________________________
From: Pantvaidya, Vishwajit [mailto:vpantvai@selectica.com]
Sent: Thursday, March 27, 2008 8:33 PM
To: axis-user@ws.apache.org
Subject: [Axis2] WstxParsingException: Expected a text token, got START_ELEMENT - while passing
array from Axis2 client to Axis2 service

Using the suggestions from the case 2 mentioned in http://wso2.org/library/332, I wrote an
Axis2 client to call my Axis2 service that has a string array as one of the params. But I
got following error when the call executes:

org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxParsingException: Expected a text token,
got START_ELEMENT.
 at [row,col {unknown-source}]: [1,401]
            at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:486)
            at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:343)
            at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:389)
            at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
            at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
            at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
            at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508)

Any suggestions?

Here is the relevant snippet from my WSDL:

<types>
<s:schema elementFormDefault="qualified" targetNamespace="http://ws.selectica.com/ecm/">
<s:element name="AssignUserToRoles">
                        <s:complexType>
                                    <s:sequence>
                                                <s:element name="SessionToken" type="s:string"></s:element>
                                                <s:element name="Email" type="s:string"></s:element>
                                                <s:element name="RoleId" type="s:string"
maxOccurs="unbounded" minOccurs="1"></s:element>
                                    </s:sequence>
                        </s:complexType>
            </s:element>
<s:element name="AssignUserToRolesResponse">
            <s:complexType></s:complexType>
</s:element>
</s:schema>
</types>

<wsdl:message name="AssignUserToRolesRequest">
            <wsdl:part name="parameters" element="tns:AssignUserToRoles"></wsdl:part>
</wsdl:message>
<wsdl:message name="AssignUserToRolesResponse">
            <wsdl:part name="parameters" element="tns:AssignUserToRolesResponse"></wsdl:part>
</wsdl:message>

<portType name="ECMServiceSoap">
            <wsdl:operation name="AssignUserToRoles">
                        <wsdl:input message="tns:AssignUserToRolesRequest"></wsdl:input>
                        <wsdl:output message="tns:AssignUserToRolesResponse"></wsdl:output>
            </wsdl:operation>
</portType>

<binding name="ECMServiceSoap" type="tns:ECMServiceSoap">
            <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
            <operation name="AssignUserToRoles">
                        <soap:operation soapAction="" style="document"/>
                        <input>
                                    <soap:body use="literal"/>
                        </input>
                        <output>
                                    <soap:body use="literal"/>
                        </output>
            </operation>
</binding>
...


And here is the client code:

svcClient = new ServiceClient();
Options options = new Options();
options.setTo(new EndpointReference(serviceURL));
options.setAction("http://localhost:8080/services/ECMServiceSoap/AssignUserToRoles");
svcClient.setOptions(options);

OMNamespace ns = fac.createOMNamespace(serviceNamespace, "ns1");
payload = fac.createOMElement("AssignUserToRoles", ns);

OMElement value = fac.createOMElement("SessionToken", ns);
value.setText(sessionId);
payload.addChild(value);

OMElement value = fac.createOMElement("Email", ns);
value.setText(email);
payload.addChild(value);

//roles is a String[]
OMElement value = BeanUtil.getOMElement(new QName(ns.getNamespaceURI(),"RoleId"), roles, null,
false, null);
payload.addChild(value);

OMElement responseElement=(OMElement) svcClient.sendReceive(payload);


Mime
View raw message