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/}stackTracerg.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">
<wsdlart name="getAStateReturn" type="soapenc:string"/>
</wsdl:message>
<wsdl:message name="getAStateRequest">
<wsdlart name="in0" type="soapenc:string"/>
</wsdl:message>
<wsdl:message name="getAllStatesResponse">
<wsdlart name="getAllStatesReturn" type="apachesoap:Vector"/>
</wsdl:message>
<wsdlortType name="States">
<wsdlperation name="getAllStates">
<wsdl:input message="impl:getAllStatesRequest"
name="getAllStatesRequest"/>
<wsdlutput message="impl:getAllStatesResponse"
name="getAllStatesResponse"/>
</wsdlperation>
<wsdlperation name="getAState" parameterOrder="in0">
<wsdl:input message="impl:getAStateRequest"
name="getAStateRequest"/>
<wsdlutput message="impl:getAStateResponse"
name="getAStateResponse"/>
</wsdlperation>
</wsdlortType>
<wsdl:binding name="statesSoapBinding" type="impl:States">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdlperation name="getAllStates">
<wsdlsoapperation soapAction=""/>
<wsdl:input name="getAllStatesRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:com:states" use="encoded"/>
</wsdl:input>
<wsdlutput name="getAllStatesResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:com:states" use="encoded"/>
</wsdlutput>
</wsdlperation>
<wsdlperation name="getAState">
<wsdlsoapperation soapAction=""/>
<wsdl:input name="getAStateRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:com:states" use="encoded"/>
</wsdl:input>
<wsdlutput name="getAStateResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:com:states" use="encoded"/>
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:service name="StatesService">
<wsdlort binding="impl:statesSoapBinding" name="states">
<wsdlsoap:address
location="http://localhost/axis/services/states"/>
</wsdlort>
</wsdl:service>
</wsdl:definitions>
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/}stackTracerg.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">
<wsdlart name="getAStateReturn" type="soapenc:string"/>
</wsdl:message>
<wsdl:message name="getAStateRequest">
<wsdlart name="in0" type="soapenc:string"/>
</wsdl:message>
<wsdl:message name="getAllStatesResponse">
<wsdlart name="getAllStatesReturn" type="apachesoap:Vector"/>
</wsdl:message>
<wsdlortType name="States">
<wsdlperation name="getAllStates">
<wsdl:input message="impl:getAllStatesRequest"
name="getAllStatesRequest"/>
<wsdlutput message="impl:getAllStatesResponse"
name="getAllStatesResponse"/>
</wsdlperation>
<wsdlperation name="getAState" parameterOrder="in0">
<wsdl:input message="impl:getAStateRequest"
name="getAStateRequest"/>
<wsdlutput message="impl:getAStateResponse"
name="getAStateResponse"/>
</wsdlperation>
</wsdlortType>
<wsdl:binding name="statesSoapBinding" type="impl:States">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdlperation name="getAllStates">
<wsdlsoapperation soapAction=""/>
<wsdl:input name="getAllStatesRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:com:states" use="encoded"/>
</wsdl:input>
<wsdlutput name="getAllStatesResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:com:states" use="encoded"/>
</wsdlutput>
</wsdlperation>
<wsdlperation name="getAState">
<wsdlsoapperation soapAction=""/>
<wsdl:input name="getAStateRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:com:states" use="encoded"/>
</wsdl:input>
<wsdlutput name="getAStateResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:com:states" use="encoded"/>
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:service name="StatesService">
<wsdlort binding="impl:statesSoapBinding" name="states">
<wsdlsoap:address
location="http://localhost/axis/services/states"/>
</wsdlort>
</wsdl:service>
</wsdl:definitions>