Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9252833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:03:24+00:00 2026-06-18T11:03:24+00:00

I’m developing a SOAP based WebService (JAX-WS) and dates come with specific format yyyymmdd.

  • 0

I’m developing a SOAP based WebService (JAX-WS) and dates come with specific format “yyyymmdd”. My WSDL defines the date as string but I would like to return a SOAP fault response when the expected format is not followed by the element value.
I’ve defined an XMLAdapter for element and tried the following in unmarshall method:

public XMLGregorianCalendar unmarshal(String value) throws Exception {
    if (!checkCorrectFormat(value)){
        throw new RuntimeException();
    }

    return ParseHelper.getInstance().parseStrDateToXMLDate(value);
}

But the exception is lost and the WebService goes on without problem getting a null XMLGregorianCalendar value for the unmarshalled element. Perhaps this is not the right place to implement this format control…
Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:03:25+00:00Added an answer on June 18, 2026 at 11:03 am

    Consider implementing this regex restriction in your xsd:

      <xsd:simpleType name="MySpecialDate">
        <xsd:restriction base="xsd:string">
          <xsd:pattern value="\d{4}\d{2}\d{2}"/>
          <xsd:whiteSpace value="collapse"/>
        </xsd:restriction>
      </xsd:simpleType>
    

    \d{4}-\d{2}-\d{2} might not be quite as strict as you need to follow the rules of a gregorian calendar. For instance, 20121312 would not be a valid gregorian date because there is no 13th month in the gregorian calendar but it would still pass your regex restriction. But you can definitely create a regex that conform to the gregorian rules with a couple google searches.

    And then, let JAXWS do the schema validation for you. see “To activate Service-side validation” on http://www.jroller.com/gmazza/entry/soap_xml_schema_validation

    Also, if you have to do the ccyymmdd format you can’t use xsd:date which, in my mind, would be preferable because Jaxb will create a java.util.Date for you as your property right from the start. You can still achieve this (generating a java.util.Date) with your custom ccyymmdd format but it is a little more work. You would probably use a jaxb custom binding. Something like this would go into your .jxb file and used with the xjc task:

    <jxb:bindings node="//xs:simpleType[@name='MySpecialDate']">
      <jxb:javaType name="java.util.Date"
            parseMethod="com.company.DateConverter.parseMySpecialDate" 
            printMethod="com.wpsic.tricare.ws.converter.DateConverter.printMySpecialDate" />
    </jxb:bindings>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am using JSon response to parse title,date content and thumbnail images and place
For some reason, after submitting a string like this Jack’s Spindle from a text
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.