0

我在 Windows 7 上维护一个旧的 apache axis 1.4 Java 程序。我的程序的输出是:EffectiveDate Fri Mar 01 00:00:00 EDT 2013

如何使 apache 轴返回日期为“YYYY-MM-DD”(例如“2013-03-01”)?即不要编写将 java.util.Date (例如“Fri Mar 01 00:00:00 EDT 2013”​​)作为输入并返回“YYYY-MM-DD”(例如“2013-03-01”)的辅助函数)。

我的程序(简化以显示主要逻辑):

private Call call;
Service service = new Service();

try{
        call = (Call) service.createCall();

         //...

        // Create Header
        SOAPHeaderElement1 = createApplicationHeader1(mainForm.getTransactionIdentifier() + "-" + threadNumber,
                                                      mainForm.getUserName(),
                                                      mainForm.getUserPassword());
        call.addHeader(SOAPHeaderElement1);
}catch(ServiceException se){
         //...
}

try{
        call.setTargetEndpointAddress(new java.net.URL(endPoint));
        call.setOperationName("getInfo");

        //...
        rpcBodyElement = new RPCElement("getInfo");
        rpcBodyElement.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/");
        rpcBodyElement.setNamespaceURI(bnwsdl);

        SOAPElement getInfoElement = rpcBodyElement.addChildElement(INFO_GET_REQUEST);
        SOAPElement typeCode = getInfoElement.addChildElement(TYPE_CODE);
        typeCode.addTextNode(mainForm.getTypeCode());

        call.setReturnType(new javax.xml.namespace.QName("http://www.mytest.com/xml_schemas/ws", "InfoGetResponseType"));
        call.setReturnClass(com.mytest.www.ws.common.InfoGetResponseType.class);
        call.setReturnQName(new javax.xml.namespace.QName("", "getInfoReturn"));

        QName qname = new QName( "http://www.mytest.com/xml_schemas/ws", "InfoGetResponseType" );
        call.registerTypeMapping(com.mytest.www.ws.common.InfoGetResponseType.class,
              qname,
              new org.apache.axis.encoding.ser.BeanSerializerFactory(com.mytest.www.ws.common.InfoGetResponseType.class, qname),
              new org.apache.axis.encoding.ser.BeanDeserializerFactory(com.mytest.www.ws.common.InfoGetResponseType.class, qname), false);

        // Invoke Web Service
        infoGetResponse = (com.mytest.www.ws.common.InfoGetResponseType) call.invoke(rpcBodyElement);
        System.out.println("EffectiveDate " + infoGetResponse.getInfoResultRow().getEffectiveDate());
}catch (MalformedURLException mue){
        //...
}
4

0 回答 0