我正在使用'wsimport'从wsdl生成客户端java代码.wsdl在这样的操作定义中有soap:header
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.test.com/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://www.test.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Test session web service methods.</wsdl:documentation>
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.test.com/">
<s:element name="Logon">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="user" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="organisation" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="LogonResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="LogonResult" type="tns:LogonResult" />
</s:sequence>
</s:complexType>
</s:element>
<s:simpleType name="LogonResult">
<s:restriction base="s:string">
<s:enumeration value="Ok" />
<s:enumeration value="Error" />
</s:restriction>
</s:simpleType>
<s:element name="Header" type="tns:Header" />
<s:complexType …Run Code Online (Sandbox Code Playgroud) 我使用jersey 1.13和spring 3.1.1编写了一个休息服务,它运行在tomcat 6上.在tomcat中,我正在使用一个将进行身份验证的领域.在我的应用程序中,我需要当前用户,但我不想在每个资源中从泽西访问SecurityContext.我想在我的其余资源中注入一个请求范围的ApplicationConfig对象,该资源将包含当前用户.稍后我可以扩展此类以包含更多请求级别配置参数.这对我来说似乎是一个很好的抽象.
@Component
@Scope(value = "request")
public class ApplicationConfig
{
private String userCode;
public String getUserCode()
{
return this.userCode;
}
public void setUserCode(String userCode)
{
this.userCode = userCode;
}
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个ApplicationConfigManager来提供对配置的访问.
@Component
public class ApplicationConfigManager
{
@Autowired
public ApplicationConfig applicationConfig;
public ApplicationConfig getApplicationConfig()
{
return this.applicationConfig;
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序配置管理器定义为单例(默认),但ApplicationConfig应该是请求范围,因此是@Scope注释.
我正在使用(jersey)ContainterRequestFilter在应用程序配置对象上设置用户.
@Component
@Provider
public class ApplicationConfigFilter implements ResourceFilter, ContainerRequestFilter
{
@Autowired
private ApplicationConfigManager applicationConfigManager;
@Override
public ContainerRequest filter(ContainerRequest request)
{
this.applicationConfigManager.getApplicationConfig().setUserCode(
request.getSecurityContext().getUserPrincipal().getName()
);
return request;
}
@Override
public ContainerRequestFilter …Run Code Online (Sandbox Code Playgroud) 如何构建一个包含测试类和测试依赖项的jar(带有maven).
我知道如何创建具有相关性(使用组件插件)的类和依赖的"主"类的jar包,但我需要的测试类和测试的依赖.
我知道我可以使用jar插件创建一个包含测试类的jar,但这不包含测试依赖项.
TIA