2

I call a method of a web service taking as parameter an class that contains an array of objects.

Inquiry obj = new Inquiry
{
    Items = new Test.Items[]
    {
        new Test.Items{ Id="1"}, 
        new Test.Items{ Id="2"}, 
        new Test.Items{ Id="3"}, 
    }
};
client.TestMethod(ref obj);

Everything works fine if I pass only one item in the Items array. When I pass two or more items I get a System.ServiceModel.FaultException with Message: The Imp. Line already exists. Identification fields and values: Import Process Code='',UID='',Line No.='0' I think it's something wrong with xml or soap serialization of complex types.

<basicHttpBinding>
<binding name="WEBInquiry_Binding">
  <security mode="Transport">
    <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm=""/>
    <message clientCredentialType="UserName" algorithmSuite="Default"/>
  </security>
</binding>

Is it something I must change in code or in configuration? Thank You

EDIT FaultException has a Code Property with Name and Namespace members

Name=Microsoft.Dynamics.Nav.Types.Exceptions.NavCSideException

Namespace=urn:microsoft-dynamics-schemas/error

albert
  • 1,493
  • 1
  • 15
  • 33
  • Are you using Microsoft Dynamics Nav? Looks like the error is coming from there. If that's the case, sounds like a bug in their software and you should be asking in their support forums. – Shadow The GPT Wizard Nov 07 '15 at 16:45
  • @ShadowWizard Yes, I updated the question – albert Nov 07 '15 at 16:53
  • Agree wirh @wizard, error comes from within Nav. So you need to inspect/debug the codeunit that handles the request. Are you sure that ws can handle arrays? Could you post the wsdl of ws or of this particular request? The binding seems meaningles here. – Mak Sim Nov 08 '15 at 06:03
  • @MakSim it looks like a parameter of TestMethod function is an XmlPort published as a reference. In this case, elements with MaxOccurs = Unbounded appear as arrays in WS. In this case, the problem may be solved by filling all the properties of Test.Items class (if they include key fields of the table). But anyway it is necessary to analyze and understand the code on the NAV side. – sergeyol Nov 08 '15 at 20:36

1 Answers1

2

The reason is that you're importing data to the Imp. Line table. In NAV the "Line" type table's primary key is often the Line No. (which is just an Integer running number). So you have three options: - You need to populate the Line No. from your code to make the Record unique - Somebody needs to change the table structure on the other side to have the primary key AutoIncremented - You have to pass your array items one-by-one

azatoth
  • 705
  • 6
  • 14