XML Port error

wwestendorpwwestendorp Member Posts: 178
WHo can Help me.

I've wrote an XML Port.
When I Try to import an XML File through that Dataport I receivean error message

The Element <DocumentReference> is expected ba the Min. Accours Value : Once
Element received <Partnerdesription

In this XML Port are more then 1 DocumentReference TagNames.

The Properties are MinOccurs:Once MaxOccurs:Unbounded

I think the error comes from elements with the same Tagname?

I got the XML Port Working by setting the MinOccurs to ZERO but then the Value would not be imported into a table.

Who is so Smart that he could Help me. ](*,)

Comments

  • wwestendorpwwestendorp Member Posts: 178
    This is a Bit of the XML Code

    - <DocumentReference type="SalesOrder">
    <DocumentNumber>1005978158</DocumentNumber>
    <DateStamp>20070504</DateStamp>
    </DocumentReference>
    - <DocumentReference type="PurchaseOrder">
    <DocumentNumber>BESF10122</DocumentNumber>
    </DocumentReference>
  • DenSterDenSter Member Posts: 8,307
    First of all, having two elements with the same name outside of a loop is not wellformed XML. You need to address that.

    If you set up an element in an XMLPort with minoccurs = 1 and a certain name, then the XMLPort will think something is wrong when that element doesn't occur in your XML document. So, you can set MinOccurs to 0, and that should take care of it.
  • DenSterDenSter Member Posts: 8,307
    Is the snippet just a little bit of your XML specification? You are missing a loop element and a root element. An XML document needs one (and one only) root element, and it needs to have a placeholder for a loop. Something like this:
    <MyRootElement>
      <DocRefLoop>
        <DocumentReference type="SalesOrder">
          <DocumentNumber>1005978158</DocumentNumber>
          <DateStamp>20070504</DateStamp>
        </DocumentReference>
        <DocumentReference type="PurchaseOrder">
          <DocumentNumber>BESF10122</DocumentNumber>
        </DocumentReference>
      </DocRefLoop>
    </MyRootElement>
    
  • wwestendorpwwestendorp Member Posts: 178
    DenSter wrote:
    Is the snippet just a little bit of your XML specification? You are missing a loop element and a root element. An XML document needs one (and one only) root element, and it needs to have a placeholder for a loop. Something like this:
    <MyRootElement>
      <DocRefLoop>
        <DocumentReference type="SalesOrder">
          <DocumentNumber>1005978158</DocumentNumber>
          <DateStamp>20070504</DateStamp>
        </DocumentReference>
        <DocumentReference type="PurchaseOrder">
          <DocumentNumber>BESF10122</DocumentNumber>
        </DocumentReference>
      </DocRefLoop>
    </MyRootElement>
    

    Hi DenSter,

    Yes it's just a piece of code.

    The Problem I have is that a suplier gives us the definition of the XML File where thos TagNames are given. Further on in the XML File are some more Tagnames which are more times in the same File.

    To set the MinOccurs to ZERO works but NO data will be received ??


    [code] <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
    - <OrderStatusResponse>
    - <SenderEnvelope>
    <SenderID>4005922010102</SenderID>
    <ReceiverID>333886948</ReceiverID>
    <DateStamp>20070504</DateStamp>
    <VersionID>1.00</VersionID>
    </SenderEnvelope>
    - <Header>
    - <StatusOverview>
    <OverallStatus>InProcess</OverallStatus>
    <DeliveryStatus>NotShipped</DeliveryStatus>
    <RejectStatus>NotRejected</RejectStatus>
    </StatusOverview>
    - <DocumentReference type="SalesOrder">
    <DocumentNumber>1005978158</DocumentNumber>
    <DateStamp>20070504</DateStamp>
    </DocumentReference>
    - <DocumentReference type="PurchaseOrder">
    <DocumentNumber>BESF10122</DocumentNumber>
    </DocumentReference>
    - <PartnerDescription type="Buyer">
    <PartnerNumber type="Distibutor">0010226070</PartnerNumber>
    <PartnerName1 />
    <PartnerName2 />
    <PartnerAddress />
    <PartnerPostalCode />
    <PartnerCity />
    </PartnerDescription>
    <DeliveryBlock>No</DeliveryBlock>
    <Currency>EUR</Currency>
    </Header>
    - <LineItem>
    - <StatusOverview>
    <OverallStatus>Open</OverallStatus>
    <DeliveryStatus>NotShipped</DeliveryStatus>
    <RejectStatus>NotRejected</RejectStatus>
    </StatusOverview>
    - <DocumentReference type="SalesOrder">
    <DocumentNumber>1005978158</DocumentNumber>
    <LineNumber>100</LineNumber>
    <Quantity>1</Quantity>
    </DocumentReference>
    - <DocumentReference type="PurchaseOrder">
    <DocumentNumber>BESF10122</DocumentNumber>
    <LineNumber>10000</LineNumber>
    <Quantity>1</Quantity>
    </DocumentReference>
    <ProductNumber type="Distributor">1001114</ProductNumber>
    <ProductNumber type="Manufacturer">C6615DE#ABD</ProductNumber>
    <ProductNumber type="Buyer" />
    <ProductDescription type="Distributor">HP Nr15 Tinte schwarz 25ml HV
    </ProductDescription>
    <Quantity type="1">1</Quantity>
    <MonetaryAmount type="NetCustomer">19.35</MonetaryAmount>
    - <Scedule>
    <DateStamp>20070504</DateStamp>
    <Quantity>1</Quantity>
    </Scedule>
    </LineItem>
    </OrderStatusResponse>
  • DenSterDenSter Member Posts: 8,307
    Read the C/SIDE reference guide (F1 help) to figure out what MinOccurs means. Setting it to zero means that the XMLPort will not freak out if there is no element with that name.
  • wwestendorpwwestendorp Member Posts: 178
    DenSter wrote:
    Read the C/SIDE reference guide (F1 help) to figure out what MinOccurs means. Setting it to zero means that the XMLPort will not freak out if there is no element with that name.

    :shock:

    Off course , I did that before but my problem is that No values will be transferred over, allthough the values are there ?
  • DenSterDenSter Member Posts: 8,307
    That property has nothing to do with the values. All it is is a property that says 'it is OK if the XML document doesn't have an element with that name, because sometimes the element is not going to be there'. If it does occur, then it should pick up the value in it.

    The issue you seem to have is that you have an element with the same name as a sub-element of an element with the same name. That is not wellformed XML. See if you can work with your vendor to modify the design of the XML.
  • DenSterDenSter Member Posts: 8,307
    Could you open the XML doc in notepad and paste the XML in here? You copied it from IE, and the '-' is throwing me off.
  • wwestendorpwwestendorp Member Posts: 178
    DenSter wrote:
    Could you open the XML doc in notepad and paste the XML in here? You copied it from IE, and the '-' is throwing me off.

    The main Proble is that the Vendor has allready with other Systems (SAP etc.) interfaces and does not want to change their design.

    I Totally aggree that it's not wellformed XML but I have to try to work with it :cry:

    <?xml version="1.0"?>
    <OrderStatusResponse>
    	<SenderEnvelope>
    		<SenderID>4005922010102</SenderID>
    		<ReceiverID>333886948</ReceiverID>
    		<DateStamp>20070504</DateStamp>
    		<VersionID>1.00</VersionID>
    	</SenderEnvelope>
    	<Header>
    		<StatusOverview>
    			<OverallStatus>InProcess</OverallStatus>
    			<DeliveryStatus>NotShipped</DeliveryStatus>
    			<RejectStatus>NotRejected</RejectStatus>
    		</StatusOverview>
    		<DocumentReference type="SalesOrder">
    			<DocumentNumber>1005978158</DocumentNumber>
    			<DateStamp>20070504</DateStamp>
    		</DocumentReference>
    		<DocumentReference type="PurchaseOrder">
    			<DocumentNumber>BESF10122</DocumentNumber>
    		</DocumentReference>
    		<PartnerDescription type="Buyer">
    			<PartnerNumber type="Distributor">0010226070</PartnerNumber>
    			<PartnerName1></PartnerName1>
    			<PartnerName2></PartnerName2>
    			<PartnerAddress></PartnerAddress>
    			<PartnerPostalCode></PartnerPostalCode>
    			<PartnerCity></PartnerCity>
    		</PartnerDescription>
    		<DeliveryBlock>No</DeliveryBlock>
    		<Currency>EUR</Currency>
    	</Header>
    	<LineItem>
    		<StatusOverview>
    			<OverallStatus>Open</OverallStatus>
    			<DeliveryStatus>NotShipped</DeliveryStatus>
    			<RejectStatus>NotRejected</RejectStatus>
    		</StatusOverview>
    		<DocumentReference type="SalesOrder">
    			<DocumentNumber>1005978158</DocumentNumber>
    			<LineNumber>100</LineNumber>
    			<Quantity>1</Quantity>
    		</DocumentReference>
    		<DocumentReference type="PurchaseOrder">
    			<DocumentNumber>BESF10122</DocumentNumber>
    			<LineNumber>10000</LineNumber>
    			<Quantity>1</Quantity>
    		</DocumentReference>
    		<ProductNumber type="Distributor">1001114</ProductNumber>
    		<ProductNumber type="Manufacturer">C6615DE#ABD</ProductNumber>
    		<ProductNumber type="Buyer"/>
    		<ProductDescription type="Distributor">HP Nr15 Tinte schwarz 25ml HV DJ840c</ProductDescription>
    		<Quantity type="Requested">1</Quantity>
    		<MonetaryAmount type="NetCustomer">19.35</MonetaryAmount>
    		<Schedule>
    			<DateStamp>20070504</DateStamp>
    			<Quantity>1</Quantity>
    		</Schedule>
    	</LineItem>
    	<LineItem>
    		<StatusOverview>
    			<OverallStatus>Open</OverallStatus>
    			<DeliveryStatus>NotShipped</DeliveryStatus>
    			<RejectStatus>NotRejected</RejectStatus>
    		</StatusOverview>
    		<DocumentReference type="SalesOrder">
    			<DocumentNumber>1005978158</DocumentNumber>
    			<LineNumber>200</LineNumber>
    			<Quantity>1</Quantity>
    		</DocumentReference>
    		<DocumentReference type="PurchaseOrder">
    			<DocumentNumber>BESF10122</DocumentNumber>
    			<Quantity>1</Quantity>
    		</DocumentReference>
    		<ProductNumber type="Distributor">7000061</ProductNumber>
    		<ProductNumber type="Manufacturer"/>
    		<ProductNumber type="Buyer"/>
    		<ProductDescription type="Distributor">Frachtkosten automatisch</ProductDescription>
    		<Quantity type="Requested">1</Quantity>
    		<MonetaryAmount type="NetCustomer">6.00</MonetaryAmount>
    		<Schedule>
    			<DateStamp>20070504</DateStamp>
    			<Quantity>1</Quantity>
    		</Schedule>
    	</LineItem>
    	<LineItem>
    		<StatusOverview>
    			<OverallStatus>Open</OverallStatus>
    			<DeliveryStatus>NotShipped</DeliveryStatus>
    			<RejectStatus>NotRejected</RejectStatus>
    		</StatusOverview>
    		<DocumentReference type="SalesOrder">
    			<DocumentNumber>1005978158</DocumentNumber>
    			<LineNumber>300</LineNumber>
    			<Quantity>1</Quantity>
    		</DocumentReference>
    		<DocumentReference type="PurchaseOrder">
    			<DocumentNumber>BESF10122</DocumentNumber>
    			<Quantity>1</Quantity>
    		</DocumentReference>
    		<ProductNumber type="Distributor">7000052</ProductNumber>
    		<ProductNumber type="Manufacturer"/>
    		<ProductNumber type="Buyer"/>
    		<ProductDescription type="Distributor">Umweltpauschale</ProductDescription>
    		<Quantity type="Requested">1</Quantity>
    		<MonetaryAmount type="NetCustomer">1.45</MonetaryAmount>
    		<Schedule>
    			<DateStamp>20070504</DateStamp>
    			<Quantity>1</Quantity>
    		</Schedule>
    	</LineItem>
    	<LineItem>
    		<StatusOverview>
    			<OverallStatus>Open</OverallStatus>
    			<DeliveryStatus>NotShipped</DeliveryStatus>
    			<RejectStatus>NotRejected</RejectStatus>
    		</StatusOverview>
    		<DocumentReference type="SalesOrder">
    			<DocumentNumber>1005978158</DocumentNumber>
    			<LineNumber>400</LineNumber>
    			<Quantity>1</Quantity>
    		</DocumentReference>
    		<DocumentReference type="PurchaseOrder">
    			<DocumentNumber>BESF10122</DocumentNumber>
    			<Quantity>1</Quantity>
    		</DocumentReference>
    		<ProductNumber type="Distributor">7003112</ProductNumber>
    		<ProductNumber type="Manufacturer"/>
    		<ProductNumber type="Buyer"/>
    		<ProductDescription type="Distributor">Transportversicherung</ProductDescription>
    		<Quantity type="Requested">1</Quantity>
    		<MonetaryAmount type="NetCustomer">1.00</MonetaryAmount>
    		<Schedule>
    			<DateStamp>20070504</DateStamp>
    			<Quantity>1</Quantity>
    		</Schedule>
    	</LineItem>
    	<LineItem>
    		<StatusOverview>
    			<OverallStatus>Open</OverallStatus>
    			<DeliveryStatus>NotShipped</DeliveryStatus>
    			<RejectStatus>NotRejected</RejectStatus>
    		</StatusOverview>
    		<DocumentReference type="SalesOrder">
    			<DocumentNumber>1005978158</DocumentNumber>
    			<LineNumber>500</LineNumber>
    			<Quantity>1</Quantity>
    		</DocumentReference>
    		<DocumentReference type="PurchaseOrder">
    			<DocumentNumber>BESF10122</DocumentNumber>
    			<Quantity>1</Quantity>
    		</DocumentReference>
    		<ProductNumber type="Distributor">7003581</ProductNumber>
    		<ProductNumber type="Manufacturer"/>
    		<ProductNumber type="Buyer"/>
    		<ProductDescription type="Distributor">Mautgebühr</ProductDescription>
    		<Quantity type="Requested">1</Quantity>
    		<MonetaryAmount type="NetCustomer">0.50</MonetaryAmount>
    		<Schedule>
    			<DateStamp>20070504</DateStamp>
    			<Quantity>1</Quantity>
    		</Schedule>
    	</LineItem>
    </OrderStatusResponse>
    
  • DenSterDenSter Member Posts: 8,307
    Alright, it seems that it is wellformed after all, just not as readable as I like it :).

    See if you can find a little program called XML Notepad, it should be on Microsoft.com somewhere. Load your XML in there and you can see the structure. Then you adjust the structure of your XMLPort to comply with it and you should be fine. Note that you will need to manipulate some of the elements with MinOccurs and MaxOccurs because they repeat, and you will need to create attribute nodes to be able to read the values in there. I'd do it for you, but I'd have to charge you for it :)
  • DenSterDenSter Member Posts: 8,307
  • wwestendorpwwestendorp Member Posts: 178
    DenSter wrote:
    Alright, it seems that it is wellformed after all, just not as readable as I like it :).

    See if you can find a little program called XML Notepad, it should be on Microsoft.com somewhere. Load your XML in there and you can see the structure. Then you adjust the structure of your XMLPort to comply with it and you should be fine. Note that you will need to manipulate some of the elements with MinOccurs and MaxOccurs because they repeat, and you will need to create attribute nodes to be able to read the values in there. I'd do it for you, but I'd have to charge you for it :)

    I did create the XML Port and it works if I set of various doubled TagNames the MinOccurs to ZERO or 0, But then Navision won't import alll that data. It will write the LAST Value of the Same TAGNAME (of the SUB) and writes it to the Field of the first TagName. The other Fields (attached to the Tagnames with th esame TagName) will be empty???

    Do you have a solution ?

    I can send you the XML File, Port and 2 Tables if needed. They's not well Named but for Tests they are okay.
  • DenSterDenSter Member Posts: 8,307
    The issue you are having is that you have probably defined the DocumentReference element more than once in the same indentation level, and your XMLPort then goes crazy.

    Create the DocumentReference element once, and allow it to repeat itself (hint: maxoccurs). Add the attribute elements indented to that element. Set the minoccurs and maxoccurs to the appropriate values and you should be fine.
  • wwestendorpwwestendorp Member Posts: 178
    Thanks for the Tip,

    I have to create and link more tables but I think that that's the only way
  • wwestendorpwwestendorp Member Posts: 178
    DenSter wrote:
    The issue you are having is that you have probably defined the DocumentReference element more than once in the same indentation level, and your XMLPort then goes crazy.

    Create the DocumentReference element once, and allow it to repeat itself (hint: maxoccurs). Add the attribute elements indented to that element. Set the minoccurs and maxoccurs to the appropriate values and you should be fine.



    Dear DenSter,

    For the DocumentReferences it works fine but for the ProductNumber type??

    These ar on the same level as the other StatusOverviews.


    How does the XMl Port handle them if I only put 1 TagName inside it. (It probably will take the last value (Buyer) in this case.

    Is it possible to write between each ProductNumer (READ and WRITE , to write some Code?)
  • wwestendorpwwestendorp Member Posts: 178
    How can I importthe values of 3 same TagNames fields into a Navision Table?
Sign In or Register to comment.