2

ユーザーが自分のプロファイルを更新できるWebサービスがあります。ここで問題となるのは、ユーザーがプロファイルの日付フィールド(たとえば、DOBまたは登録日)を空白にしたい場合、ユーザーがを送信すると、応答は次のようになります。

<faultcode>ns1:Client</faultcode>
<faultstring>Unmarshalling Error:</faultstring>

soapUIを使用して日付を空白にするにはどうすればよいですか?私はたくさん検索し、nillableを試しましたが、無駄でした。

テクノロジー:jaxb

アプリケーションコンソールの出力は次のとおりです。

    16:05:39,508 INFO  [WSCallbackHandler] WSPasswordCallback attempt: rd
16:05:39,534 INFO  [STDOUT] DefaultValidationEventHandler: [ERROR]:  
     Location: line 0
16:05:39,534 WARNING [PhaseInterceptorChain] Interceptor for {http://abc.com/services/}ProfileUpdateService#{http://abc.com/services/}updateProfile has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error:  
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:773)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:624)
    at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:128)
    at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:109)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:110)
    at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98)
    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:423)
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:178)
    at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:142)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
Caused by: javax.xml.bind.UnmarshalException
 - with linked exception:
[javax.xml.bind.UnmarshalException: 
 - with linked exception:
[java.lang.IllegalArgumentException: ]]
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:425)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:755)
    ... 33 more
Caused by: javax.xml.bind.UnmarshalException: 
 - with linked exception:
[java.lang.IllegalArgumentException: ]
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:642)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:671)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:667)
    at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.handleParseConversionException(Loader.java:267)
    at com.sun.xml.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:65)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:494)
    at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.text(InterningXmlVisitor.java:89)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.processText(StAXStreamConnector.java:334)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleEndElement(StAXStreamConnector.java:212)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:181)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
    ... 35 more
Caused by: javax.xml.bind.UnmarshalException: 
 - with linked exception:
[java.lang.IllegalArgumentException: ]
    ... 46 more
Caused by: java.lang.IllegalArgumentException: 
    at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parseYear(Unknown Source)
    at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parse(Unknown Source)
    at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl.<init>(Unknown Source)
    at org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(Unknown Source)
    at com.sun.xml.bind.DatatypeConverterImpl._parseDateTime(DatatypeConverterImpl.java:397)
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$4.parse(RuntimeBuiltinLeafInfoImpl.java:280)
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$4.parse(RuntimeBuiltinLeafInfoImpl.java:282)
    at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.parse(TransducedAccessor.java:243)
    at com.sun.xml.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:61)
    ... 41 more
4

1 に答える 1

1

使用するXmlAdapter

 public class Foo 
 {
     @XmlJavaTypeAdapter(DateAdapter.class)
     YourDateTimeType hashmap;
     ...
 }  

とアダプター

public class DateAdapter extends XmlAdapter<YourDateTimeType, String>
{

   @Override
   public String unmarshal(YourDateTimeType v) throws Exception
   {
      // your date time to string
   }

   @Override
   public YourDateTimeType marshal(String v) throws Exception
   {
      // string to your date time
   }

}  

アダプタでは、フィールドが空かどうかを確認できます

于 2012-09-07T13:19:17.560 に答える