Client Application for Apache Axis Web Services

G

gabsaga.tata

The following client application works fine when I pass in a state code
which returns the full state name as a string.
On the other hand, if I don't pass in any arguments, it should return a
vector of StateObj objects but this doesn't seem to be working because
I get the exception below.
There are no compile time errors or warnings.
I have also included the WSDL. Any help will be greatly appreciated.
Thanks. Gabsaga

package com.states;

import java.util.Vector;

public class StatesClient
{
public static void main(String [] args) throws Exception
{
// Make a service
com.ws.StatesService service = new com.ws.StatesServiceLocator();

// Now use the service to get a stub to the service
com.ws.States st = service.getstates();

if (args.length == 0)
{
Vector vec = new Vector();
vec = st.getAllStates();
StateObj obj = null;
String stateName = null;
String stateCode = null;

System.out.println("State Code \t\t State Name");
System.out.println("----------------------------------------");
for (int i = 0; i < vec.size(); i++)
{
obj = (StateObj)vec.elementAt(i);
stateCode = obj.getStateCode();
stateName = obj.getStateName();
System.out.println(stateCode + "\t\t" + stateName);
}
}
else
{
String stateCode = args[0];

// Make the actual call
System.out.println("State name for code " + stateCode + " = " +
st.getAState(stateCode.toUpperCase()));
}
}
}


**************** ************************* *********************
************************

Exception in thread "main" AxisFault
faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: Document root element is
missing.
faultActor:
faultNode:
faultDetail:

{http://xml.apache.org/axis/}stackTrace:eek:rg.xml.sax.SAXParseException:
D
ocument root element is missing.
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3364)
at
org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:668)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)

at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at
org.apache.axis.encoding.DeserializationContext.parse(Deserialization
Context.java:227)
at
org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
at
org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnders
tandChecker.java:62)
at
org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2765)
at org.apache.axis.client.Call.invoke(Call.java:2748)
at org.apache.axis.client.Call.invoke(Call.java:2424)
at org.apache.axis.client.Call.invoke(Call.java:2347)
at org.apache.axis.client.Call.invoke(Call.java:1804)
at
com.ws.StatesSoapBindingStub.getAllStates(StatesSoapBindingStub.java:
112)
at com.states.StatesClient.main(StatesClient.java:18)

{http://xml.apache.org/axis/}hostname:MYHOSTNAME

org.xml.sax.SAXParseException: Document root element is missing.
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at
org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
at
org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnders
tandChecker.java:62)
at
org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2765)
at org.apache.axis.client.Call.invoke(Call.java:2748)
at org.apache.axis.client.Call.invoke(Call.java:2424)
at org.apache.axis.client.Call.invoke(Call.java:2347)
at org.apache.axis.client.Call.invoke(Call.java:1804)
at
com.ws.StatesSoapBindingStub.getAllStates(StatesSoapBindingStub.java:
112)
at com.states.StatesClient.main(StatesClient.java:18)
Caused by: org.xml.sax.SAXParseException: Document root element is
missing.
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3364)
at
org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:668)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)

at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at
org.apache.axis.encoding.DeserializationContext.parse(Deserialization
Context.java:227)
at
org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
... 10 more


**************** ************************* *********************
************************
WSDL
**************** ************************* *********************
************************

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="urn:com:states"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="urn:com:states" xmlns:intf="urn:com:states"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.2.1
Built on Jun 14, 2005 (09:15:57 EDT)-->
<wsdl:types>
<schema targetNamespace="http://xml.apache.org/xml-soap"
xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="Vector">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="item"
type="xsd:anyType"/>
</sequence>
</complexType>
</schema>
</wsdl:types>

<wsdl:message name="getAllStatesRequest">

</wsdl:message>

<wsdl:message name="getAStateResponse">

<wsdl:part name="getAStateReturn" type="soapenc:string"/>

</wsdl:message>

<wsdl:message name="getAStateRequest">

<wsdl:part name="in0" type="soapenc:string"/>

</wsdl:message>

<wsdl:message name="getAllStatesResponse">

<wsdl:part name="getAllStatesReturn" type="apachesoap:Vector"/>

</wsdl:message>

<wsdl:portType name="States">

<wsdl:eek:peration name="getAllStates">

<wsdl:input message="impl:getAllStatesRequest"
name="getAllStatesRequest"/>

<wsdl:eek:utput message="impl:getAllStatesResponse"
name="getAllStatesResponse"/>

</wsdl:eek:peration>

<wsdl:eek:peration name="getAState" parameterOrder="in0">

<wsdl:input message="impl:getAStateRequest"
name="getAStateRequest"/>

<wsdl:eek:utput message="impl:getAStateResponse"
name="getAStateResponse"/>

</wsdl:eek:peration>

</wsdl:portType>

<wsdl:binding name="statesSoapBinding" type="impl:States">

<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdl:eek:peration name="getAllStates">

<wsdlsoap:eek:peration soapAction=""/>

<wsdl:input name="getAllStatesRequest">

<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:com:states" use="encoded"/>

</wsdl:input>

<wsdl:eek:utput name="getAllStatesResponse">

<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:com:states" use="encoded"/>

</wsdl:eek:utput>

</wsdl:eek:peration>

<wsdl:eek:peration name="getAState">

<wsdlsoap:eek:peration soapAction=""/>

<wsdl:input name="getAStateRequest">

<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:com:states" use="encoded"/>

</wsdl:input>

<wsdl:eek:utput name="getAStateResponse">

<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:com:states" use="encoded"/>

</wsdl:eek:utput>

</wsdl:eek:peration>

</wsdl:binding>

<wsdl:service name="StatesService">

<wsdl:port binding="impl:statesSoapBinding" name="states">

<wsdlsoap:address
location="http://localhost/axis/services/states"/>

</wsdl:port>

</wsdl:service>

</wsdl:definitions>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top