如何设置webservice头域
1个回答
展开全部
//如何设置webservice头域:参数不够时,通过头域传参前大数,好处:不用动接口
//必须罩悔乎要判断头头域长度,负责每次都会增加
if (((org.apache.axis.client.Stub)WebServiceStubHelper.getXXStub()).getHeaders().length == 0)
{
SOAPHeaderElement head1 = new SOAPHeaderElement(
"soapAuthAccount", "soapAuthAccount");
head1.addTextNode(soapAuthAccount);
head1.setActor(null);
head1.setPrefix("");
head1.setMustUnderstand(false);
((org.apache.axis.client.Stub)WebServiceStubHelper.getXXStub()).setHeader(head1);
SOAPHeaderElement head2 = new SOAPHeaderElement(
"soapAuthPasswd", "物悉soapAuthPasswd");
head2.addTextNode(soapAuthPasswd);
head2.setActor(null);
head2.setPrefix("");
head2.setMustUnderstand(false);
((org.apache.axis.client.Stub)WebServiceStubHelper.getXXStub()).setHeader(head2);
}
SOAPHeaderElement[] heads = ((org.apache.axis.client.Stub)WebServiceStubHelper.getXXStub()).getHeaders();
try
{
System.out.println("soapAuthAccount:" + heads[0]);
System.out.println("soapAuthPasswd:" + heads[1]);
}
catch (Exception e)
{
e.printStackTrace();
}
//必须罩悔乎要判断头头域长度,负责每次都会增加
if (((org.apache.axis.client.Stub)WebServiceStubHelper.getXXStub()).getHeaders().length == 0)
{
SOAPHeaderElement head1 = new SOAPHeaderElement(
"soapAuthAccount", "soapAuthAccount");
head1.addTextNode(soapAuthAccount);
head1.setActor(null);
head1.setPrefix("");
head1.setMustUnderstand(false);
((org.apache.axis.client.Stub)WebServiceStubHelper.getXXStub()).setHeader(head1);
SOAPHeaderElement head2 = new SOAPHeaderElement(
"soapAuthPasswd", "物悉soapAuthPasswd");
head2.addTextNode(soapAuthPasswd);
head2.setActor(null);
head2.setPrefix("");
head2.setMustUnderstand(false);
((org.apache.axis.client.Stub)WebServiceStubHelper.getXXStub()).setHeader(head2);
}
SOAPHeaderElement[] heads = ((org.apache.axis.client.Stub)WebServiceStubHelper.getXXStub()).getHeaders();
try
{
System.out.println("soapAuthAccount:" + heads[0]);
System.out.println("soapAuthPasswd:" + heads[1]);
}
catch (Exception e)
{
e.printStackTrace();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询