You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Lucio Crusca <lu...@sulweb.org> on 2012/01/30 15:44:19 UTC

Problems parsing XML

I'm still trying to build an axis2 client, but I'm not skilled enough to find 
the problem here, so I ask for your advice. This is a long post, sorry.

When I run the ADB client, I get:

org.apache.axis2.databinding.ADBException: Unexpected subelement return

When I run the Xmlbeans client, I get no excpetions but a null result

sc_response.getSystemConnectResponse().getSystemConnectResult() == null

I suspect both problems have a common cause, e.g. the WSDL defines a 
systemConnectResponse data structure that the systemConnect service does not 
honor, so the generated axis clients (xmlbeans and adb) can't parse it.

Here is a snippet of the WSDL (I've cut the real one so that this contains 
only one method, but I believe it's still a well formed and valid WSDL):

<?xml version="1.0"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" 
xmlns:tns="https://xxx.yyy.zzz/wss-demo/SoapServer/soap" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-
enc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Services_System" 
targetNamespace="https://xxx.yyy.zzz/wss-demo/SoapServer/soap">
  <types>
    <xsd:schema targetNamespace="https://xxx.yyy.zzz/wss-
demo/SoapServer/soap">
      <xsd:element name="systemConnect">
        <xsd:complexType/>
      </xsd:element>
      <xsd:element name="systemConnectResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="systemConnectResult" type="soap-enc:Array"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
  </types>
  <portType name="Services_SystemPort">
    <operation name="systemConnect">
      <documentation>systemConnect: return the SessionId for the 
connection</documentation>
      <input message="tns:systemConnectIn"/>
      <output message="tns:systemConnectOut"/>
    </operation>
  </portType>
  <binding name="Services_SystemBinding" type="tns:Services_SystemPort">
    <soap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="systemConnect">
      <soap:operation soapAction="https://xxx.yyy.zzz/wss-
demo/SoapServer/soap#systemConnect"/>
      <input>
        <soap:body use="literal" namespace="https://xxx.yyy.zzz/wss-
demo/SoapServer/soap"/>
      </input>
      <output>
        <soap:body use="literal" namespace="https://xxx.yyy.zzz/wss-
demo/SoapServer/soap"/>
      </output>
    </operation>  
  </binding>
  <service name="Services_SystemService">
    <port name="Services_SystemPort" binding="tns:Services_SystemBinding">
      <soap:address location="https://xxx.yyy.zzz/wss-demo/SoapServer/soap"/>
    </port>
  </service>
  <message name="systemConnectIn">
    <part name="parameters" element="tns:systemConnect"/>
  </message>
  <message name="systemConnectOut">
    <part name="parameters" element="tns:systemConnectResponse"/>
  </message>
</definitions>

And here is the xml I receive from the systemConnect call:

<?xml  version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns1="https://xxx.yyy.zzz/wss-demo/SoapServer/soap" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-
ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <ns1:systemConnectResponse>
      <return xsi:type="ns2:Map">
        <item>
          <key xsi:type="xsd:string">sessid</key>
          <value xsi:type="xsd:string">q1p2uot1au238ge56odulbfiv4</value>
        </item>
        <item>
          <key xsi:type="xsd:string">user</key>
          <value xsi:type="ns2:Map">
            <item>
              <key xsi:type="xsd:string">uid</key>
              <value xsi:type="xsd:int">0</value>
            </item>
            <item>
              <key xsi:type="xsd:string">hostname</key>
              <value xsi:type="xsd:string">172.20.80.68</value>
            </item>
            <item>
              <key xsi:type="xsd:string">roles</key>
              <value xsi:type="ns2:Map">
                <item>
                  <key xsi:type="xsd:int">1</key>
                  <value xsi:type="xsd:string">anonymous user</value>
                </item>
              </value>
            </item>
            <item>
              <key xsi:type="xsd:string">session</key>
              <value xsi:type="xsd:string"></value>
            </item>
            <item>
              <key xsi:type="xsd:string">cache</key>
              <value xsi:type="xsd:int">0</value>
            </item>
          </value>
        </item>
      </return>
    </ns1:systemConnectResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I've replaced the real server name with xxx.yyy.zzz.

Can anyone tell me if this XML response is valid as per the wsdl schema and 
what eventually should be changed (in the wsdl) to make it valid? 
Unfortunately I couldn't find any validation service that lets me upload both 
the XML and the WSDL as XSD.

Thanks in advace
Lucio.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: Problems parsing XML

Posted by Sagara Gunathunga <sa...@gmail.com>.
On Tue, Jan 31, 2012 at 12:18 AM, Lucio Crusca <lu...@sulweb.org> wrote:

> In data lunedì 30 gennaio 2012 18:05:52, Deepal Jayasinghe ha scritto:
> > How did you generate the code ? did you use the ?wsdl and generate the
> > stubs or did you do something else.
>
> I used the ?wsdl and generated the stubs with the following commands:
>
> $AXIS2_HOME/bin/wsdl2java.sh -uri https://xxx.yyy.zzz/wss-demo/SoapServer/-p
> zzz.yyy.xxx.webservices.client.xmlbeans -s -o src-xmlbeans -d xmlbeans
>
> $AXIS2_HOME/bin/wsdl2java.sh -uri https://xxx.yyy.zzz/wss-demo/SoapServer/-p
> zzz.yyy.xxx.webservices.client.adb -s -o src-adb -Eiu -d adb
>
> using axis2 1.7-SNAPSHOT for -Eiu option (but the same happens with 1.6
> without the -Eiu option).
>

I think problem is not with above -Eiu option instead with your WSDL, above
WSDL use SOAP encoding that Axis2 does not support.  In some cases it's
possible to use XMLBean data binding to deal with SOAP encoding ( refer
[1]) but I'm not sure whether it will help out in this case.

[1] - http://ssagara.blogspot.com/2011/10/soap-encoding-and-axis2.html

Thanks !


>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>


-- 
Sagara Gunathunga

Blog      - http://ssagara.blogspot.com
Web      - http://people.apache.org/~sagara/
LinkedIn - http://www.linkedin.com/in/ssagara

Re: Problems parsing XML

Posted by Lucio Crusca <lu...@sulweb.org>.
In data lunedì 30 gennaio 2012 18:05:52, Deepal Jayasinghe ha scritto:
> How did you generate the code ? did you use the ?wsdl and generate the
> stubs or did you do something else.

I used the ?wsdl and generated the stubs with the following commands:

$AXIS2_HOME/bin/wsdl2java.sh -uri https://xxx.yyy.zzz/wss-demo/SoapServer/ -p 
zzz.yyy.xxx.webservices.client.xmlbeans -s -o src-xmlbeans -d xmlbeans

$AXIS2_HOME/bin/wsdl2java.sh -uri https://xxx.yyy.zzz/wss-demo/SoapServer/ -p 
zzz.yyy.xxx.webservices.client.adb -s -o src-adb -Eiu -d adb

using axis2 1.7-SNAPSHOT for -Eiu option (but the same happens with 1.6 
without the -Eiu option).


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: Problems parsing XML

Posted by Deepal Jayasinghe <de...@opensource.lk>.
How did you generate the code ? did you use the ?wsdl and generate the
stubs or did you do something else.

Deepal

> I'm still trying to build an axis2 client, but I'm not skilled enough to find 
> the problem here, so I ask for your advice. This is a long post, sorry.
>
> When I run the ADB client, I get:
>
> org.apache.axis2.databinding.ADBException: Unexpected subelement return
>
> When I run the Xmlbeans client, I get no excpetions but a null result
>
> sc_response.getSystemConnectResponse().getSystemConnectResult() == null
>
> I suspect both problems have a common cause, e.g. the WSDL defines a 
> systemConnectResponse data structure that the systemConnect service does not 
> honor, so the generated axis clients (xmlbeans and adb) can't parse it.
>
> Here is a snippet of the WSDL (I've cut the real one so that this contains 
> only one method, but I believe it's still a well formed and valid WSDL):
>
> <?xml version="1.0"?>
> <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" 
> xmlns:tns="https://xxx.yyy.zzz/wss-demo/SoapServer/soap" 
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-
> enc="http://schemas.xmlsoap.org/soap/encoding/" 
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Services_System" 
> targetNamespace="https://xxx.yyy.zzz/wss-demo/SoapServer/soap">
>   <types>
>     <xsd:schema targetNamespace="https://xxx.yyy.zzz/wss-
> demo/SoapServer/soap">
>       <xsd:element name="systemConnect">
>         <xsd:complexType/>
>       </xsd:element>
>       <xsd:element name="systemConnectResponse">
>         <xsd:complexType>
>           <xsd:sequence>
>             <xsd:element name="systemConnectResult" type="soap-enc:Array"/>
>           </xsd:sequence>
>         </xsd:complexType>
>       </xsd:element>
>   </types>
>   <portType name="Services_SystemPort">
>     <operation name="systemConnect">
>       <documentation>systemConnect: return the SessionId for the 
> connection</documentation>
>       <input message="tns:systemConnectIn"/>
>       <output message="tns:systemConnectOut"/>
>     </operation>
>   </portType>
>   <binding name="Services_SystemBinding" type="tns:Services_SystemPort">
>     <soap:binding style="document" 
> transport="http://schemas.xmlsoap.org/soap/http"/>
>     <operation name="systemConnect">
>       <soap:operation soapAction="https://xxx.yyy.zzz/wss-
> demo/SoapServer/soap#systemConnect"/>
>       <input>
>         <soap:body use="literal" namespace="https://xxx.yyy.zzz/wss-
> demo/SoapServer/soap"/>
>       </input>
>       <output>
>         <soap:body use="literal" namespace="https://xxx.yyy.zzz/wss-
> demo/SoapServer/soap"/>
>       </output>
>     </operation>  
>   </binding>
>   <service name="Services_SystemService">
>     <port name="Services_SystemPort" binding="tns:Services_SystemBinding">
>       <soap:address location="https://xxx.yyy.zzz/wss-demo/SoapServer/soap"/>
>     </port>
>   </service>
>   <message name="systemConnectIn">
>     <part name="parameters" element="tns:systemConnect"/>
>   </message>
>   <message name="systemConnectOut">
>     <part name="parameters" element="tns:systemConnectResponse"/>
>   </message>
> </definitions>
>
> And here is the xml I receive from the systemConnect call:
>
> <?xml  version="1.0" encoding="UTF-8"?>
> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
> xmlns:ns1="https://xxx.yyy.zzz/wss-demo/SoapServer/soap" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
> xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-
> ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-
> ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
>   <SOAP-ENV:Body>
>     <ns1:systemConnectResponse>
>       <return xsi:type="ns2:Map">
>         <item>
>           <key xsi:type="xsd:string">sessid</key>
>           <value xsi:type="xsd:string">q1p2uot1au238ge56odulbfiv4</value>
>         </item>
>         <item>
>           <key xsi:type="xsd:string">user</key>
>           <value xsi:type="ns2:Map">
>             <item>
>               <key xsi:type="xsd:string">uid</key>
>               <value xsi:type="xsd:int">0</value>
>             </item>
>             <item>
>               <key xsi:type="xsd:string">hostname</key>
>               <value xsi:type="xsd:string">172.20.80.68</value>
>             </item>
>             <item>
>               <key xsi:type="xsd:string">roles</key>
>               <value xsi:type="ns2:Map">
>                 <item>
>                   <key xsi:type="xsd:int">1</key>
>                   <value xsi:type="xsd:string">anonymous user</value>
>                 </item>
>               </value>
>             </item>
>             <item>
>               <key xsi:type="xsd:string">session</key>
>               <value xsi:type="xsd:string"></value>
>             </item>
>             <item>
>               <key xsi:type="xsd:string">cache</key>
>               <value xsi:type="xsd:int">0</value>
>             </item>
>           </value>
>         </item>
>       </return>
>     </ns1:systemConnectResponse>
>   </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
> I've replaced the real server name with xxx.yyy.zzz.
>
> Can anyone tell me if this XML response is valid as per the wsdl schema and 
> what eventually should be changed (in the wsdl) to make it valid? 
> Unfortunately I couldn't find any validation service that lets me upload both 
> the XML and the WSDL as XSD.
>
> Thanks in advace
> Lucio.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>

-- 
Blog - http://blogs.deepal.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org