how to generate a xml with a custom namespace

1
hello, i created a custom schema for exporting a xml file. but the xml that is generated always has a ns1 namespace. i post my xsd schema here: <?xml version="1.0" encoding="utf-8" ?> <xsd:schema targetNamespace="urn:schemas-qad-com:xml-services:common" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:qcom="urn:schemas-qad-com:xml-services:common"> <xsd:element name="dsSessionContext"> <xsd:complexType> <xsd:sequence> <xsd:element name="ttContext" minOccurs="0" maxOccurs="unbounded" type="qcom:TtContextType" /> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:complexType name="TtContextType"> <xsd:sequence> <xsd:element name="propertyQualifier" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="1" /> <xsd:element name="propertyName" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="1" /> <xsd:element name="propertyValue" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="1" /> </xsd:sequence> </xsd:complexType> </xsd:schema> the export shows this as result: <ns1:dsSessionContext xmlns:ns1="urn:schemas-qad-com:xml-services:common"> <ns1:ttContext> <ns1:propertyQualifier>QAD</ns1:propertyQualifier> <ns1:propertyName>entity</ns1:propertyName> <ns1:propertyValue>Test</ns1:propertyValue> </ns1:ttContext> <ns1:ttContext> <ns1:propertyQualifier>QAD</ns1:propertyQualifier> <ns1:propertyName>domain</ns1:propertyName> </ns1:ttContext> <ns1:ttContext> <ns1:propertyQualifier>QAD</ns1:propertyQualifier> <ns1:propertyName>scopeTransaction</ns1:propertyName> <ns1:propertyValue>true</ns1:propertyValue> </ns1:ttContext> <ns1:ttContext> <ns1:propertyQualifier>QAD</ns1:propertyQualifier> <ns1:propertyName>version</ns1:propertyName> <ns1:propertyValue>ERP3_1</ns1:propertyValue> </ns1:ttContext> <ns1:ttContext> <ns1:propertyQualifier>QAD</ns1:propertyQualifier> <ns1:propertyName>mnemonicsRaw</ns1:propertyName> <ns1:propertyValue>false</ns1:propertyValue> </ns1:ttContext> <ns1:ttContext> <ns1:propertyQualifier>QAD</ns1:propertyQualifier> <ns1:propertyName>action</ns1:propertyName> <ns1:propertyValue>save</ns1:propertyValue> </ns1:ttContext> <ns1:ttContext> <ns1:propertyQualifier>QAD</ns1:propertyQualifier> <ns1:propertyName>email</ns1:propertyName> </ns1:ttContext> <ns1:ttContext> <ns1:propertyQualifier>QAD</ns1:propertyQualifier> <ns1:propertyName>emailLevel</ns1:propertyName> </ns1:ttContext> </ns1:dsSessionContext> i would expect a <qcom: namespace.<="" p=""> anyone here that can point me in the right direction ? Best regards,
asked
1 answers
1

This is by default not possible. Your only option would be to use a domain to xml mapping activity and then read the xml as a string using the community commons StringFromFile() java action.

You can then replace the namespace by one of your own. And do the webservice call with a custom java action

private IWebserviceResponse callWebservice(String location, String soapAction, String soapRequestMessage) throws WebserviceException, IOException{

    IWebserviceResponse WebserviceResponse = com.mendix.core.Core.callWebservice(location, soapAction, soapRequestMessage);

    return WebserviceResponse;
}

private String WebserviceResponseToString(IWebserviceResponse webserviceResponse) throws IOException {
    StringWriter writer = new StringWriter();
    IOUtils.copy(webserviceResponse.getStream(), writer, "UTF-8");
    String theString = writer.toString();

    return theString;
}

Which from which you will get the response in string format. You can then turn that string to a file document by using the CommunityCommons java action StringToFile(). And us a microflow activity "Import XML" to actually map that XML to your data.

Or you could just accept the ns1 namespace :)

answered