我正在尝试在我的网络服务中使用ServletContext
,但WebServiceContext
总是NULL
。任何人都可以告诉我我做错了什么,我使用的是spring framework和tomcat。< / p>
package com.xyz.webser;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Resource;
import javax.jws.WebService;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletContext;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
@WebService(serviceName = "myWebService", endpointInterface = "com.xyz.webser.MyWebService")
public class MyWebServiceImpl implements MyWebService {
@Resource
private WebServiceContext context;
public void setContext(WebServiceContext context) {
this.context = context;
}
答案 0 :(得分:0)
我在服务包中创建了一个新的java文件,使用了“implements ServletContextAware” 从Web服务中调用该方法。