This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Services and the fly likes Unable to add a date in the SOAPElement while calling a web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Unable to add a date in the SOAPElement while calling a web service" Watch "Unable to add a date in the SOAPElement while calling a web service" New topic
Author

Unable to add a date in the SOAPElement while calling a web service

lakshmi desai
Greenhorn

Joined: Feb 28, 2008
Posts: 16
I have written a java client that consumes .NET web service. The web service takes few string values and a date which is type DATE. The xsi:type is "date".I am using SOAPElement to add all the input values, but I cannot add the date field, since it accepts only string and I get the below exception:

Can somebody help me with this?how I can pass the date value?

Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
faultSubcode:
faultString: Server was unable to read request. ---> There is an error in XML document (1, 801). ---> String was not recognized as a valid DateTime.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:Server was unable to read request. ---> There is an error in XML document (1, 801). ---> String was not recognized as a valid DateTime.
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:1910)
at com.ess.vv.util.TestWeb.callUsingCustomEnvelope(TestWeb.java:196)
at com.ess.vv.util.TestWeb.main(TestWeb.java:83)

Thanks in advance.
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1175
Hi Lakshmi,

Can you show us please the SOAP request?

Regards,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
lakshmi desai
Greenhorn

Joined: Feb 28, 2008
Posts: 16
Dan,

Here is the SOAPRequest

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<PollingPlaceRequest xmlns="http://tempuri.org/">
<pollingRequest xmlns="http://tempuri.org/Request.xsd/">
<version>v1</version>
<byVoter xmlns="http://tempuri.org/Request.xsd/">
<LastName>CRESPO</LastName>
<DOB>02/24/1948</DOB>
<VoterID>17259</VoterID>
</byVoter>
</pollingRequest>
</PollingPlaceRequest>
</soap:Body>
</soap:Envelope>
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1175
Hi Lakshmi,

http://tempuri.org/Request.xsd doesn't seem to point to an XML Schema Definition.

Regards,
Dan
Doug Slattery
Ranch Hand

Joined: Sep 15, 2007
Posts: 294
Hi Lakshmi,

Maybe it's a DateTime problem related to this thread.

Hope that helps...
Aloha,
Doug

-- Nothing is impossible if I'mPossible
lakshmi desai
Greenhorn

Joined: Feb 28, 2008
Posts: 16
Dan,

Its a valid xml schema definition.

Doug,

I have gone through the thread and mine is different.
I need to send a date value to the web service adding it as a SOAPElement.

Thanks for your reply.
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1175
Originally posted by lakshmi desai:
Dan,

Its a valid xml schema definition.



Oh - please check it :roll:
[ May 06, 2008: Message edited by: Dan Drillich ]
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by lakshmi desai:
{http://xml.apache.org/axis/}stackTrace:Server was unable to read request. ---> There is an error in XML document (1, 801). ---> There is an error in XML document (1, 801). ---> String was not recognized as a valid DateTime.



<DOB>02/24/1948</DOB>


XML Schema Part 2: 3 Built-in datatypes, 3.2 Primitive datatypes, 3.2.9 date

So the above date isn't a valid XMLSchema date. It should be:


<DOB>1948-02-24</DOB>

[ May 06, 2008: Message edited by: Peer Reynders ]
lakshmi desai
Greenhorn

Joined: Feb 28, 2008
Posts: 16
Thanks Peer, it worked. I am not getting the error message now.
I am working on the other part of it and if I need any help I will post my problem....Thanks again for your suggestion....
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Dan Drillich:
{http://tempuri.org/Request.xsd} doesn't seem to point to an XML Schema Definition.


It doesn't have to. Namespace names are URIs (Universal Resource Identifier), not URLs (Universal Resource Locators). It isn't mandatory that somebody publish the schema at the identical URL. It is the schemaLocation attribute that is used to identify the location of the schema. And that isn't always used either because tools rather use their own configured location so that they can use a cached version, rather that accessing the schema over the network every time they need it.

Please see also:
XML namespace url doubt
Resolving relative URIs for Canonicalization
Need explanations about urn and uri for a targetNamespace

It is however sloppy to use the tempuri.org domain. Tools like Visual Studio .NET always use this as the default - it is supposed to be replaced with the domain name of your organization in order to avoid global (as in the whole internet) namespace collisions. "tempuri.org" roughly stands for "temporary uri for your organization" - i.e. "place your organization's domain name here".
[ May 06, 2008: Message edited by: Peer Reynders ]
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1175
Thank you Peer!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to add a date in the SOAPElement while calling a web service