[ http://issues.apache.org/jira/browse/AXIS-2436?page=comments#action_12371200 ]
George Cowe commented on AXIS-2436: ----------------------------------- I have found a workaround to this problem - The problem is caused by the test client's SOAPBodyElement constructor which takes a org.w3c.dom.Document as an argument. There seems to be a bug with this Axis class constructor. If I switch to using the SOAPBodyElement with an InputStream as a constructor the problem goes away. > using call.invoke() from client java program to invoke web service inserts > empty namespace on all elements in message sent > -------------------------------------------------------------------------------------------------------------------------- > > Key: AXIS-2436 > URL: http://issues.apache.org/jira/browse/AXIS-2436 > Project: Apache Axis > Type: Bug > Components: Serialization/Deserialization > Versions: 1.3 > Environment: Windows XP > Reporter: George Cowe > > I am attempting to use the message-style processing in a web service > implemented in Axis 1.3. The client java program creates a SOAPBodyElement > from my XML and uses call.invoke() to send it to the service. > Using XMLUtils.DocumentToString() I can see that the org.w3c.Document has > been created successfully from the XML. > However the error message returned states : > org.xml.sax.SAXParseException: The value of the attribute > "prefix="xmlns",localpart="ce",rawname="xmlns:ce"" is invalid. Prefixed > namespace bindings may not be empty. > Using a TCP/IP monitor I can see that Axis has inserted a blank namespace on > all elements: xmlns:ce="". > The XML used to create the org.w3c.Document validates against my schema > (which has a targetNameSpace defined as well as the xmlns:ce namespace). > So I do not understand why the empty namespaces are being added to the > document. > The client java program looks like this > package co.origoservices.ws.client; > import java.io.File; > import java.io.IOException; > import java.net.URL; > import java.util.Vector; > import javax.xml.namespace.QName; > import javax.xml.parsers.DocumentBuilder; > import javax.xml.parsers.DocumentBuilderFactory; > import javax.xml.parsers.ParserConfigurationException; > import org.apache.axis.client.Call; > import org.apache.axis.client.Service; > import org.apache.axis.message.SOAPBodyElement; > import org.apache.axis.utils.XMLUtils; > import org.w3c.dom.Document; > import org.xml.sax.SAXException; > public class MsgClient { > public static void main(String[] args) throws Exception { > if (args.length != 1) { > System.out.println("Please supply an xml filename"); > System.exit(1); > } > String xmlFileName = args[0]; > Document doc = null; > DocumentBuilderFactory factory = > DocumentBuilderFactory.newInstance(); > try { > DocumentBuilder builder = factory.newDocumentBuilder(); > doc = builder.parse(new File(xmlFileName)); > } catch (SAXException sxe) { > // Error generated during parsing > Exception x = sxe; > if (sxe.getException() != null) > x = sxe.getException(); > x.printStackTrace(); > } catch (ParserConfigurationException pce) { > // Parser with specified options can't be built > pce.printStackTrace(); > } catch (IOException ioe) { > // I/O error > ioe.printStackTrace(); > } > System.out.println("sending " + XMLUtils.DocumentToString(doc)); > Service service = new Service(); > Call call = (Call) service.createCall(); > // String endpoint = > "http://localhost:8181/AxisTestWeb/services/CEBondSingleContractService"; > String endpoint = > "http://localhost:10766/AxisTestWeb/services/CEBondSingleContractService"; > call.setTargetEndpointAddress(new URL(endpoint)); > String operation = "echoDocument"; > call.setOperation(new QName(endpoint, operation), operation); > SOAPBodyElement body = new > SOAPBodyElement(doc.getDocumentElement()); > Vector result = (Vector) call.invoke(new Object[] { body }); > SOAPBodyElement sbe = (SOAPBodyElement) result.get(0); > System.out.println("received " + > XMLUtils.DocumentToString(sbe.getAsDocument())); > } > } > the input XML looks like this > <?xml version="1.0" encoding="ISO-8859-1"?> > <ce:ce_bond_single_contract_request > xmlns:ce="http://www.origostandards.com/schema/ce/v2" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xsi:schemaLocation="http://www.origostandards.com/schema/ce/v2 > ce_bond_single_contract_request.xsd"> > <ce:b_control> > > <ce:contract_enquiry_reference>CE123456</ce:contract_enquiry_reference> > </ce:b_control> > <ce:intermediary> > <ce:company_name>IFA Company Ltd</ce:company_name> > <ce:contact_details> > <ce:name>Mr Fred Smith</ce:name> > <ce:telephone_number>0131 523 4480</ce:telephone_number> > </ce:contact_details> > </ce:intermediary> > <ce:request_scope> > > <ce:contract_details_required_ind>No</ce:contract_details_required_ind> > <ce:valuation_currency>GBP</ce:valuation_currency> > <ce:fund_code_type_required>SEDOL</ce:fund_code_type_required> > <ce:valuation_request type="Current"/> > </ce:request_scope> > <ce:contract> > > <ce:contract_reference_number>A-284762-01</ce:contract_reference_number> > </ce:contract> > </ce:ce_bond_single_contract_request> > > and the abbreviated schema looks like this > <?xml version="1.0" encoding="ISO-8859-1"?> > <xsd:schema targetNamespace="http://www.origostandards.com/schema/ce/v2" > xmlns:ce="http://www.origostandards.com/schema/ce/v2" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > elementFormDefault="qualified" > attributeFormDefault="unqualified" version="2.0"> > <xsd:element name="ce_bond_single_contract_request"> > <xsd:complexType> > <xsd:sequence> > <xsd:element ref="ce:b_control" minOccurs="0"/> > <xsd:element name="intermediary" > type="ce:IntermediaryForAuthentication" minOccurs="0"/> > <xsd:element ref="ce:request_scope"/> > <xsd:element ref="ce:contract"/> > </xsd:sequence> > <xsd:attributeGroup ref="ce:CommonAttributes"/> > </xsd:complexType> > </xsd:element> > ..... > Any advice would be much appreciated. > > -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira