相关疑难解决方法(0)

Spring:标准日志方面(拦截器)

我已经找到了很多关于如何使用像这样或者这样的Spring框架创建自定义方面的示例,但没有找到针对这种情况和问题的标准/常见Spring实现.Spring是否有任何标准的日志记录方面实现?

java logging spring aspectj

22
推荐指数
1
解决办法
1万
查看次数

Web服务与CXF:如何使用ResponseWrapper?

我们正在使用以下方法创建一个由java类(Java2WS)驱动的Web服务(基于CXF):

  @WebMethod
  @RequestWrapper(className = "com.myproject.wrapper.MyRequestWrapper")
  @ResponseWrapper(className = "com.myproject.wrapper.MyResponseWrapper")
  public MyResponse verifyCode(@WebParam(name = "code") String code) {
    ...
    return new MyResponse("Hello",StatusEnum.okay);
  }
Run Code Online (Sandbox Code Playgroud)

我使用包装器来定义请求resp的元素.更详细的响应:正确的元素名称(以大写字符开头),必需元素和可选元素,...).但我不确定这是否是正确的方法(没有关于包装器的深入文档,不是吗?)

MyResponse类:

public class MyResponseWrapper {

  private String result;   
  private ModeEnum status;

  // getters and setters
}
Run Code Online (Sandbox Code Playgroud)

MyReponseWrapper类

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "myResponse")
public class MyResponseWrapper {

  @XmlElement(name="Result")
  private String result;

  @XmlElement(name = "Status")
  private StatusEnum status;

  public MyResponseWrapper() {
    result="fu"; // just for testing
  }

  // getters and setters
}
Run Code Online (Sandbox Code Playgroud)

目前我不了解Wrappers.当我返回MyReponse的一个实例时,MyResponse的数据如何被分别注入MyResponseWrapper到响应的SOAP主体?

通过测试这个Web服务,我可以看到MyResponseWrapper的实例被实例化,SOAP主体包含正确的元素,但是包含默认数据(例如:result ="fu"而不是"Hello").我预计CXF会将MyResponse的匹配数据注入MyResponseWrapper.那是错的吗?

如果这是错误的方法:在使用Java2WS时,Wat是指定生成的SOAP xml的正确方法吗?

顺便说一下:上面的源代码片段只是从我们更复杂(更多字段)类中获取的示例.

java web-services cxf response wrapper

10
推荐指数
1
解决办法
8458
查看次数

标签 统计

java ×2

aspectj ×1

cxf ×1

logging ×1

response ×1

spring ×1

web-services ×1

wrapper ×1