我有一个SEI
@WebService
@SOAPBinding
(
style = javax.jws.soap.SOAPBinding.Style.DOCUMENT,
use = javax.jws.soap.SOAPBinding.Use.LITERAL
)
@HandlerChain(file = "securityhandler.xml")
public interface UserService
{
@WebMethod
public AuthenticateResponse authenticateUser(AuthenticateRequest request,@WebParam(header = true, mode = Mode.IN) ApplicationCredentials credential);
}
我正在使用wsgen生成服务器端类文件和wsdl。我注意到wsgen在我的请求(AuthenticateRequest)上生成了包装器
package com.ecourt.ws.jaxws;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.ecourt.ws.impl.request.AuthenticateRequest;
@XmlRootElement(name = "authenticateUser", namespace = "http://ws.ecourt.com/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "authenticateUser", namespace = "http://ws.ecourt.com/")
public class AuthenticateUser {
@XmlElement(name = "arg0", namespace = "")
private AuthenticateRequest arg0;
/**
*
* @return
* returns AuthenticateRequest
*/
public AuthenticateRequest getArg0() {
return this.arg0;
}
/**
*
* @param arg0
* the value for the arg0 property
*/
public void setArg0(AuthenticateRequest arg0) {
this.arg0 = arg0;
}
}
现在我使用LogicalHandler拦截SOAP Message并尝试将有效负载解组为AuthenticateRequest,它会引发异常:
javax.xml.ws.WebServiceException:javax.xml.bind.UnmarshalException:unexpected element(uri:“http://ws.ecourt.com/”,local:“authenticateUser”)。预期元素为< {} authenticateRequest>,< {} baseRequest>
我的处理程序的句柄消息实现是
@Override
public boolean handleMessage(LogicalMessageContext messageContext) {
try
{
System.out.println("in handle messgae of AuthenticationHandler");
Boolean outboundProperty = (Boolean)
messageContext.get (MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if(outboundProperty == false)
{
JAXBContext jc = JAXBContext.newInstance(com.ecourt.ws.impl.request.AuthenticateRequest.class);
Object obj = messageContext.getMessage().getPayload(jc);
}
}
catch(Exception ex)
{
ex.printStackTrace();
return false;
}
return true;
}
这是xsd
的一部分<xs:element name="authenticateUser" type="tns:authenticateUser"/>
<xs:complexType name="authenticateUser">
<xs:sequence>
<xs:element name="arg0" type="tns:authenticateRequest" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
我只想将UnMarshall payLoad直接发送给AuthenticateRequest而不是WSGen生成的AuthenticateUser。有什么办法吗?任何帮助都将受到高度赞赏
答案 0 :(得分:1)
这解决了,我需要使用LogicalMessage Class中的另一个重载方法: Source source = messageContext.getMessage()。getPayload(); 通过源代码,我们可以处理完整的Soap地址。
由于