Nullable java.util.Date datatypes

Hi,

I been able to create a web service based on a flow service using web service descriptor. One of the flow services I’m developing has in the output field values one of type java.util.Date that can be nullable.

When I test (SOAPUI) the web service created based on this flow and the field brings data everything is fine. But, when the field is NULL , an error is displaying “Invalid date value: wrong type:” is shown… Also, when I call the same web service from a .Net application I get an “Invalid XSD”, when the values is null.

So, what is the correct data type for date values that can be null.

I’m using IS 7.1.1

Do you have this <xsd: element type=“xsd: dateTime” name=“BIRTHDATE” minOccurs=“0” maxOccurs=“1” nillable=“true” /> in the XSD? Is you current xsd always expect for BIRTHDATE element to be present/mandatory??

You shoudn’t send this way and nullable indicates:

…so can you test with/without scenario also?

HTH,
RMG

Hi,

I have the following: in the WSDL generated by Integration Server.

<xsd:element name="BIRTHDATE" nillable="true" type="xsd:dateTime" />

The max and min occurrence doesn’t appear because it isn’t a list.

Do <[FONT=Verdana]BIRTHDATE[/font]> mean NULL or does it mean Empty?

When I test with a record that has a birth date it responds without error <BIRTHDATE>1979-04-02T00:00:00.000</BIRTHDATE>,

But when I select a record with a null birth date the response is <BIRTHDATE/>, throwing also a validation error.

  • line 26: Invalid date value: wrong type:

“The max and min occurrence doesn’t appear because it isn’t a list”
– include it in the xsd

"Do <[FONT=Verdana]BIRTHDATE[/font]> mean NULL or does it mean Empty?"
It indicates node is still present and doesn’t consider as null…you can test the same with Branch statement sequences with $null and $default …and it will definetly go into $default sequence.But if you get length of it then it returns 0.

– this considers empty/null

HTH,
RMG

How do I change the WSDL/XSD when is auto generated by the Integration Server? The only place where I set the properties of these fields (required, allow null, etc) is in the flow input/output panel. From these properties is where I believe that the types section of the WSDL is auto generated.

The step to create the web service has been:

  • Created an adapter service that returns a result set.
  • Created a Flow Service that calls that adapter and map the result to the output document. In this document is where I set required and allow null properties to the fields.
  • Created a Web Service Descriptor selecting the previous created flow service.
  • Tested the WS with a tool like SOAPUI.


The properties max/min occurrences aren’t part of the constraints that can be set to these fields. Is there actually a XSD that is generated by the IS, that can be change?

Thanks for all the help,
Francisco Pereira

I assumed you have created WSD consumer via WSDL/xsd’s which creates connectors,IS elements doctypes etc.Anyways you can’t edit unless provider updates and regenerates those xsd’s again.

So that means you have created WSD provider and generated WSDL/xsd’s edited the DocumentType and set allow null =true and Required=false?? Are you also doing any schema validation(schema:validate) in your flow? At what step is it failing?? Can you step thru the flow have with and handle the logic for null condition by checking its length?

HTH,
RMG

Yes, I created a WSD provider based on a flow service. In that flow service is where I set the allow null = true and required = false on the desired field of the output document.

When the flow is run it doesn’t fail, the expected output is always returned. The fields with data show data and the fields without data show a red null value.

[FONT=Times New Roman]The problem is when I called that flow via the web service. When I call that thru SOAPUI fields that return null and aren’t string are seen as invalid types.[/font]

[SIZE=3][/size]
Do I have to change all nullable fields to type string?

Yes another option to resolve it would be change the fields types to xsd:string and it works better.

HTH,
RMG

below will allow data time and null
<xs:element name=“ApplicationDate” type=“emptydateTime” minOccurs=“0” />

<xs:simpleType name="emptydateTime">
    <xs:union>
        <xs:simpleType>
            <xs:restriction base="xs:string">
            <xs:minLength value="0" />
            <xs:maxLength value="0" />
        </xs:restriction>
        </xs:simpleType>
        <xs:simpleType>
            <xs:restriction base="xs:date" />
        </xs:simpleType>
    </xs:union>
</xs:simpleType>

This minOccurs=“0” only works for xsd:string types only and this allows null during runtime…Is that true? Did you test pass for xsd:date type also?

for e.g:
– indicates null and upon test run it works only for xsd:string not xsd:date type

TIA,
RMG

I tested for my project… It worked for me…

XML

or
2008-01-01

XSD checks for empty string or datetime format
<xs:element name=“ApplicationDate” type=“emptydateTime” minOccurs=“0” />
<xs:simpleType name=“emptydateTime”>
xs:union
xs:simpleType
<xs:restriction base=“xs:string”>
<xs:minLength value=“0” />
<xs:maxLength value=“0” />
</xs:restriction>
</xs:simpleType>
xs:simpleType
<xs:restriction base=“xs:date” />
</xs:simpleType>
</xs:union>
</xs:simpleType>

Please test with this also as it was the original issue about:

also worked for me.

XML and XSD - already posted… here is the code which validate it… Let me know if i am diviating from your question.

Public Sub ValidateXML(ByVal xml As String, ByVal schemaLocation As String, ByVal type As String, ByVal nameSpace1 As String)

    ' Loading XML
    Dim oXDoc As XmlDocument = New XmlDocument
    oXDoc.Load(xml)
    Dim sNewImportXml As StringBuilder = New StringBuilder
    sNewImportXml.Append("<Cases xsi:schemaLocation=""urn:asset-schema RenewalProcess.xsd"" xmlns=""urn:asset-schema"" xmlns:xsi=""[URL]http://www.w3.org/2001/XMLSchema-instance[/URL]"">")
    If Not oXDoc.SelectSingleNode("//Cases") Is Nothing Then
        sNewImportXml.Append(oXDoc.SelectSingleNode("//Cases").InnerXml)
    End If
    sNewImportXml.Append("</Cases>")
    'Create the XmlParserContext.
    Dim context As New XmlParserContext(Nothing, Nothing, "", XmlSpace.None)
    Dim myXmlValidatingReader As XmlValidatingReader = Nothing
    'Implement the reader. 
    myXmlValidatingReader = New XmlValidatingReader(sNewImportXml.ToString(), XmlNodeType.Element, context)
    Dim myXsdReader As XmlTextReader
    myXsdReader = New XmlTextReader(schemaLocation)
    myXmlValidatingReader.ValidationType = ValidationType.Schema
    Dim myXmlSchemaCollection As XmlSchemaCollection = New XmlSchemaCollection
    myXmlSchemaCollection.Add(nameSpace1, myXsdReader, New XmlUrlResolver)
    myXmlValidatingReader.Schemas.Add(myXmlSchemaCollection)
    myXmlValidatingReader.ValidationType = ValidationType.Auto
    ' Set the validation event handler
    AddHandler myXmlValidatingReader.ValidationEventHandler, AddressOf ValidationCallBack
    Try
        While myXmlValidatingReader.Read()
        End While
    Catch ex As Exception
        myXsdReader.Close()
        myXmlValidatingReader.Close()

         CreateMessageAlert(Me.Page, ex.Message, "Input Required")
        m_Success = False
    End Try
    myXsdReader.Close()
    myXmlValidatingReader.Close()
End Sub

Which tool were you using??

Did you try the same in the wM Developer IDE? via service: pub.schema:validateagainst xml schema??

mine is visual studio 2003. vb.net project.

But defining the XSD should be same for anything… Did you try modifying your XSD like the way i defined and test it?

XSD has string and Datetime combination…

emptydateTime - can be empty or null or should have valid date.

Goodluck!!

Uh!!..

Actually this is exclusively a webMethods user forum and sorry not a VB/.net specific.

But the original issue we have is while trying a web service test in webMethods tool (Developer IDE) when the XML element sent with -null its erroring out for xsd:date and minOccurs=0…Ofcourse its working with xsd:string type…

Anyways you have shared some useful info.

Have a nice day!
RMG