I had this exact problem myself and wasted a good half day on fixing it because of how vague the error message is. The problem is with your SOAP service (NOT the client implementation). It's throwing an error because there is a namespace issue with the XML you are sending to the client.
There are three possible reasons for the issue according to this article:
- A null namespace prefix
- A namespace prefix of "xml" that is not in the namespaceURI of "http://www.w3.org/XML/1998/namespace"
- A namespace prefix of "xmlns" that is not in the namespaceURI of "http://www.w3.org/2000/xmlns/"
In my case it was #1 above that caused the problem. I wasn't returning the XML with a namespace. I fixed it by adding a namespace (the "ns" variable) to the root element and all child nodes like so:
Namespace ns = Namespace.getNamespace("tns", "http://mycompany.com/schemas");
Element result = new Element("ResponseType", ns);
Document doc = new Document(result);
result.addContent(new Element("StatusCode", ns).setText(code));
result.addContent(new Element("Message", ns).setText(message));
It's important to note that my example code is for JDom, not Dom4j as the person was asking. You'll have to use the code appropriate for the XML library you happen to be using.