How can I get Axis 1.4 to not generate several prefixes for the same XML namespace?

Alter your client's wsdd to set enableNamespacePrefixOptimization to true.

I'd like a good list of what I can do to configure the client, preferably without reading the actual source code. – Ian McLaird Oct 9 '08 at 20:53 I found that parameter by looking through an old project. Does it work?

– Stephen Denne Oct 10 '08 at 1:42.

I have the same issue. For the moment, I've worked around it by writing a BasicHandler extension, and then walking the SOAPPart myself and moving the namespace reference up to a parent node. I don't like this solution, but it does seem to work.

I really hope somebody comes along and tells us what we have to do. EDIT This is way too complicated, and like I said, I don't like it at all, but here we go. I actually broke the functionality into a few classes (This wasn't the only manipulation that we needed to do in that project, so there were other implementations) I really hope that somebody can fix this soon.

This uses dom4j to process the XML passing through the SOAP process, so you'll need dom4j to make it work. Public class XMLManipulationHandler extends BasicHandler { private static Log log = LogFactory. GetLog(XMLManipulationHandler.

Class); private static List processingHandlers; public static void setProcessingHandlers(List handlers) { processingHandlers = handlers; } protected Document process(Document doc) { if (processingHandlers == null) { processingHandlers = new ArrayList(); processingHandlers. Add(new EmptyProcessingHandler()); } log. Trace(processingHandlers); treeWalk(doc.getRootElement()); return doc; } protected void treeWalk(Element element) { for (int I = 0, size = element.nodeCount(); I Node(i); for (int handlerIndex = 0; handlerIndex WriteTo(baos); baos.flush(); baos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); SAXReader saxReader = new SAXReader(); Document doc = saxReader.

Read(bais); doc = process(doc); DocumentSource ds = new DocumentSource(doc); soapPart. SetContent(ds); message.saveChanges(); } catch (Exception e) { throw new AxisFault("Error Caught processing document in XMLManipulationHandler", e); } } } } public interface ProcessingHandler { public Node process(Node node); } public class NamespaceRemovalHandler implements ProcessingHandler { private static Log log = LogFactory. GetLog(NamespaceRemovalHandler.

Class); private Namespace namespace; private String targetElement; private Set ignoreElements; public NamespaceRemovalHandler() { ignoreElements = new HashSet(); } public Node process(Node node) { if (node instanceof Element) { Element element = (Element) node; if (element.isRootElement()) { // Evidently, we never actually see the root node when we're called from // SOAP... } else { if (element.getName(). Equals(targetElement)) { log. Trace("Found the target Element.

Adding requested namespace"); Namespace already = element. GetNamespaceForURI(namespace.getURI()); if (already == null) { element. Add(namespace); } } else if (!ignoreElements.

Contains(element.getName())) { Namespace target = element. GetNamespaceForURI(namespace.getURI()); if (target! = null) { element.

Remove(target); element. SetQName(new QName(element.getName(), namespace)); } } Attribute type = element. Attribute("type"); if (type!

= null) { log. Trace("Replacing type information: " + type.getText()); String typeText = type.getText(); typeText = typeText. ReplaceAll("ns0-9+", namespace.getPrefix()); type.

SetText(typeText); } } } return node; } public Namespace getNamespace() { return namespace; } public void setNamespace(Namespace namespace) { this. Namespace = namespace; } /** * @return the targetElement */ public String getTargetElement() { return targetElement; } /** * @param targetElement the targetElement to set */ public void setTargetElement(String targetElement) { this. TargetElement = targetElement; } /** * @return the ignoreElements */ public Set getIgnoreElements() { return ignoreElements; } /** * @param ignoreElements the ignoreElements to set */ public void setIgnoreElements(Set ignoreElements) { this.

IgnoreElements = ignoreElements; } public void addIgnoreElement(String element) { this.ignoreElements. Add(element); } } No warranty, etc, etc.

For the Request I use this to remove namespaces types: String endpoint = "localhost:5555/yourService"; // Parameter to be send Integer secuencial = new Integer(11); // 0011 // Make the call Service service = new Service(); Call call = (Call) service.createCall(); // Disable sending Multirefs call. SetOption( org.apache.axis.AxisEngine. PROP_DOMULTIREFS, new java.lang.

Boolean( false) ); // Disable sending xsi:type call. SetOption(org.apache.axis.AxisEngine. PROP_SEND_XSI, new java.lang.

Boolean( false)); // XML with new line call. SetOption(org.apache.axis.AxisEngine. PROP_DISABLE_PRETTY_XML, new java.lang.

Boolean( false)); // Other Options. You will not need them call. SetOption(org.apache.axis.AxisEngine.

PROP_ENABLE_NAMESPACE_PREFIX_OPTIMIZATION, new java.lang. Boolean( true)); call. SetOption(org.apache.axis.AxisEngine.

PROP_DOTNET_SOAPENC_FIX, new java.lang. Boolean( true)); call. SetTargetEndpointAddress(new java.net.

URL(endpoint)); call. SetSOAPActionURI("http://YourActionUrl");//Optional // Opertion Name //call. SetOperationName( "YourMethod" ); call.

SetOperationName(new javax.xml.namespace. QName("http://yourUrl", "YourMethod")); // Do not send encoding style call. SetEncodingStyle(null); // Do not send xmlns in the xml nodes call.

SetProperty(org.apache.axis.client.Call. SEND_TYPE_ATTR, Boolean. FALSE); /////// Configuration of namespaces org.apache.axis.description.

OperationDesc oper; org.apache.axis.description. ParameterDesc param; oper = new org.apache.axis.description.OperationDesc(); oper. SetName("InsertaTran"); param = new org.apache.axis.description.

ParameterDesc(new javax.xml.namespace. QName("http://yourUrl", "secuencial"), org.apache.axis.description.ParameterDesc. IN, new javax.xml.namespace.

QName("http://www.w3.org/2001/XMLSchema", "int"), int. Class, false, false); oper. AddParameter(param); oper.

SetReturnType(new javax.xml.namespace. QName("http://www.w3.org/2001/XMLSchema", "int")); oper. SetReturnClass(int.

Class); oper. SetReturnQName(new javax.xml.namespace. QName("http://yourUrl", "yourReturnMethod")); oper.

SetStyle(org.apache.axis.constants.Style. WRAPPED); oper. SetUse(org.apache.axis.constants.Use.

LITERAL); call. SetOperation(oper); Integer ret = (Integer) call. Invoke( new java.lang.

Object { secuencial }).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions