locked
remove namespace prefix from xsi:type RRS feed

Answers

  • Once I had a similar problem with Dynamics Navision, since all the XML that I needed to send should be without namespaces or prefixes. At the time I made a Pipeline component to strip the message out of the namespaces.
    Friday, April 5, 2013 11:19 AM

All replies

  • If don't refer/inherit from any schema and if you want to remove the referenced namespaces, remove it from the imports collection:

    Also to remove the namespace prefixes, make your ElementsFromDefault as unqualified.


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.

    Wednesday, April 3, 2013 1:36 PM
  • Hi, it does Inhert from a schema. CustomerCreateRequest is in the http://schemas.microsoft.com/dynamics/2008/01/services schema and it inherts from the Customer schema.
    Wednesday, April 3, 2013 1:43 PM
  • Except CustomerCreateRequest you can remove other references.

    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.

    Wednesday, April 3, 2013 1:47 PM
  • The problem is that I need the service schema for others schemas aswell. I'm using it for several different calls (Customer, GeneralJournal, vendtable etc.)

    Wednesday, April 3, 2013 1:58 PM
  • You do not have an option because the root element "CustomerServiceCreateRequest" is defined in "http://schemas.microsoft.com/dynamics/2008/01/services" while the element in question "AxdEntity_DirParty_DirPerson" is defined in "http://schemas.microsoft.com/dynamics/2008/01/documents/Customer" so you cannot drop the namespace in the xsi:type definition.

    The maximum you can do is drop all the other namespaces which are not used in this instance i.e.; ns1: to ns5: and ns7: to ns9: and your message would look like

    <ns0:CustomerServiceCreateRequest xmlns:ns0="http://schemas.microsoft.com/dynamics/2008/01/services"
                                      xmlns:ns6="http://schemas.microsoft.com/dynamics/2008/01/documents/Customer"
                                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    	<ns6:Customer>
    		<ns6:CustTable class="entity">
    			<ns6:AccountNum>PersonId_0</ns6:AccountNum>
    			<ns6:CustGroup>GroupId_0</ns6:CustGroup>
    			<ns6:PaymTermId></ns6:PaymTermId>
    			<ns6:DirParty xsi:type="ns6:AxdEntity_DirParty_DirPerson" class="entity">
    				<ns6:Name>FirstName_0 LastName_0</ns6:Name>
    				<ns6:PrimaryContactEmail>0</ns6:PrimaryContactEmail>
    				<ns6:PrimaryContactPhone>0</ns6:PrimaryContactPhone>
    				<ns6:DirPartyPostalAddressView class="entity">
    					<ns6:City>BillingCity_0</ns6:City>
    				</ns6:DirPartyPostalAddressView>
    			</ns6:DirParty>
    		</ns6:CustTable>
    	</ns6:Customer>
    </ns0:CustomerServiceCreateRequest>

    Regards.
    Wednesday, April 3, 2013 2:43 PM
  • You can remove ns6 from xsi:type provided you add xmlns attribute to AxdEntity_DirParty_DirPerson on DirParty element again. However I am not sure why do you need to do it. If your xml is valid as per schema then what's the issue?
    Wednesday, April 3, 2013 3:56 PM
  • If you can change your schema then try to set AxdEntity_DirParty_DirPerson 's Data Structure Type as (ComplexType) instead of (ReferenceType), this will remove the prefix from your node.
    Wednesday, April 3, 2013 5:58 PM
  • the Issue is that Dynamics AX does not understand the prefix and cannot find "ns6:AxdEntity_DirParty_DirPerson"
    Thursday, April 4, 2013 6:46 AM
  • Hi, The dirparty records data structure is set to AxdEntity_DirParty_DirPerson(ComplexType).
    Thursday, April 4, 2013 6:55 AM
  • Hmmm.... the AX Schemas should be similar to CRM schemas in which case this is a case where the DirParty can hold multiple types of structures. Can you try replacing <ns6:DirParty xsi:type="ns6:AxdEntity_DirParty_DirPerson" class="entity"> with <ns6:AxdEntity_DirParty_DirPerson xsi:type="ns6:DirParty" class="entity"> and check if the message is accepted.

    Regards.

    Thursday, April 4, 2013 7:12 AM
  • get a new error:

     The element 'CustTable' in namespace 'http://schemas.microsoft.com/dynamics/2008/01/documents/Customer' has invalid child element 'AxdEntity_DirParty_DirPerson'

    When I send in a message that does not have table inheritance it works with the prefixes. and the error from ax when I try my CustomerSchema is: "Invalid Name at intancetype: "Ns6: AxdEntity_DirParty_DirPerson".

    looking like this it works:

    <?xml version="1.0"?>
    -<CustomerServiceCreateRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="-<Customer">http://schemas.microsoft.com/dynamics/2008/01/services">-<Customer xmlns="-<CustTable">http://schemas.microsoft.com/dynamics/2008/01/documents/Customer">-<CustTable class="entity"><AccountNum>PersonId_0</AccountNum><CustGroup>GroupId_0</CustGroup><PaymTermId/>-<DirParty class="entity" xsi:type="AxdEntity_DirParty_DirPerson"><Name>FirstName_0 LastName_0</Name><PrimaryContactEmail>0</PrimaryContactEmail><PrimaryContactPhone>0</PrimaryContactPhone></DirParty></CustTable></Customer></CustomerServiceCreateRequest>

    But as I said, with scehams that does not have table inheritance it works even with all the reference and namespace prefixes...

    Thursday, April 4, 2013 8:41 AM
  • Did your problem solved? 

    Molly,
    Please Mark as the Answer, if this answers your question. Please vote as helpful, if this post is helpful.

    Friday, April 5, 2013 8:58 AM
  • Once I had a similar problem with Dynamics Navision, since all the XML that I needed to send should be without namespaces or prefixes. At the time I made a Pipeline component to strip the message out of the namespaces.
    Friday, April 5, 2013 11:19 AM
  • Hi,

    I am facing the same problem uploading Customer Master to AX. Even when I remove the prefix using custom pipeline, the error still persist.

    The following error was returned: This is an invalid xsi:type 'ns6:AxdEntity_DirParty_DirPerson'.   <-- Error

    Invalid document schema. The following error was returned: This is an invalid xsi:type 'AxdEntity_DirParty_DirPerson'   <-- Also Error

    Did you manage to solve this problem? I think the prefix namespace is not an issue, even when you validate the generated xml with the schema, without prefix namespace (ns6 removed) will give you error. It could be something else. Appreciate if anyone can share their experience.

    Thanks.


    • Edited by Coure Sportivo Thursday, July 18, 2013 3:28 AM change the error caption
    Thursday, July 18, 2013 2:55 AM
  • Hi all,

    Just an update, I found the solution. AX AIF doesnt support prefix namespace like ns6 so you have to remove them in your outgoing schema. Not only in the xsi:type="ns6:AxdEntity_DirParty_DirPerson" statement but also in the root node xmlns:ns6="http://schemas.microsoft.com/dynamics/2008/01/documents/Customer".  Not sure if this is a bug or what but well I hope they can fix this in AIF in later version.

    You will have to change above to:

    xsi:type="AxdEntity_DirParty_DirPerson" and xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Customer".

    You can use custom pipeline to do this.

    Hope this help.

    Thursday, July 18, 2013 5:47 AM
  • I made the same experience with mapping for AX. Because this is well formed XML I think it must be a bug in AX.

    To go around this alternatively to a custom pipeline you can use custom XSL (like described in e.g. http://blogical.se/blogs/johan/archive/2008/01/07/removing-xml-namespace-in-a-pipeline-component.aspx)

    For an organization node you must replace

    <xsl:attribute name="xsi:type">

    <xsl:value-of select="'ns:10AxdEntity_DirParty_DirOrganization'" />

    </xsl:attribute>

    to

    <xsl:attribute name="xsi:type">

    <xsl:value-of select="'AxdEntity_DirParty_DirOrganization'" />

    </xsl:attribute>

    You will get an error in mapping test, but this will work for AX.


    • Proposed as answer by Coure Sportivo Tuesday, September 24, 2013 6:06 AM
    • Edited by Stefan Franken Tuesday, January 10, 2017 8:31 AM Link was broken
    Friday, August 30, 2013 9:14 PM