gpt4 book ai didi

datetime - 如何清空 SOAP Web 服务中的日期时间字段?

转载 作者:行者123 更新时间:2023-12-05 06:47:12 29 4
gpt4 key购买 nike

我有一个网络服务,用户可以使用该服务更新他/她的个人资料。现在的问题是,如果用户想要清空其个人资料中的任何日期字段(例如 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

最佳答案

使用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
}

}

在适配器中,您可以检查字段是否为空

关于datetime - 如何清空 SOAP Web 服务中的日期时间字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12304321/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com