Hello to all,
First, I'm Adela and I'm using axis2 Java, version 1.4.1.
I am dealing with consuming a web service from a supplier.
They require in the message header mustUnderstand='1'. The problem is
that they send us in the message header the following error:
"org.apache.axis2.AxisFault: Must Understand check failed for header
http://www.ebxml.org/namespaces/messageHeader : MessageHeader at
org.apache.axis2.engine.AxisEngine.checkMustUnderstand(AxisEngine.java:102)"
So, to handle MustUnderstand and to avoid error, I created my own
method:
class MustUnderstarnd extends AbstractHandler{ public InvocationResponse
invoke() ..
to set 'processed' the header block, so the checkMustUnderstand wouldn't
return an error.
I also added this lines inside my code:
ServiceStub stub = new ServiceStub( wsUrl );
AxisConfiguration conf=
stub._getServiceClient().getAxisConfiguration().getAxisConfiguration();
ArrayList<AbstractHandler> al = new ArrayList<AbstractHandler>();
al.add(new MustUnderstandHandler());
conf.setInPhasesUptoAndIncludingPostDispatch(al);
Also, as you can see from the attachment, I took data from the header
message response, because axis2 doesn't provide this info..
The problem is, using the method that is in attachment, for the second
request the envelope header is null. So the only solution that I found
until now is to restart the tomcat.. But this is not a very good
solution :D I think that this method is overwriting something, but as
much as debug I'm doing I can't figure out what..
Thanks for your time,
Adela
class MustUnderstandHandler extends AbstractHandler{
public InvocationResponse invoke(MessageContext msgContext)
throws AxisFault {
SOAPEnvelope envelope = msgContext.getEnvelope();
SOAPHeader header = envelope.getHeader();
if( header!= null ){
RolePlayer roleP = (RolePlayer)msgContext.getConfigurationContext().getAxisConfiguration().getParameterValue("rolePlayer");
Iterator<?> headerBlocks = header.getHeadersToProcess(roleP);
if( headerBlocks!= null ){
String secId = "";
String commId = "";
while (headerBlocks.hasNext()) {
SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next();
QName headerName = headerBlock.getQName();
// if this header block has been processed or mustUnderstand isn't
// turned on then its cool
if( ("http://schemas.xmlsoap.org/ws/2002/12/secext".equals(headerName.getNamespaceURI())
&&
"Security".equals(headerName.getLocalPart()))
||
("http://www.ebxml.org/namespaces/messageHeader".equals(headerName.getNamespaceURI())
&&
"MessageHeader".equals(headerName.getLocalPart()))
){
String[] res = new String[4];
if( "http://schemas.xmlsoap.org/ws/2002/12/secext".equals(headerName.getNamespaceURI())
&&
"Security".equals(headerName.getLocalPart()) ) {
res = FrmStringa.getRegExpGroup(headerBlock.toString(), "(<[^:]*):BinarySecurityToken([^>]*)>([^<]*)<");
if(res != null) {
secId = res[3];
}
}
if( "http://www.ebxml.org/namespaces/messageHeader".equals(headerName.getNamespaceURI())
&&
"MessageHeader".equals(headerName.getLocalPart()) ) {
res = FrmStringa.getRegExpGroup(headerBlock.toString(), "<([^:]*):ConversationId([^>]*)>([^<]*)<");
if(res != null) {
commId = res[3];
}
}
synchronized (connIDMap_semaphore) {
connIDMap.put(commId, secId);
}
}
if ( headerBlock.getMustUnderstand()) {
headerBlock.setProcessed();
}
}
}
}
return InvocationResponse.CONTINUE;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]