首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NAV服务如何通过C#更新数据?

NAV服务如何通过C#更新数据?
EN

Stack Overflow用户
提问于 2013-10-01 12:42:52
回答 1查看 1.8K关注 0票数 0

所以,如果我做错了什么,请容忍我。我一直试图从C#更新Nav中的一些数据,但是无论我做什么,我都会得到错误:

我的代码单元如下所示,这是我需要用来更新的方法:

代码语言:javascript
复制
<operation name="OpdaterVogn">
    <operation soapAction="urn:microsoft-dynamics-schemas/codeunit/BMG:OpdaterVogn"style="document"/>
  <input name="OpdaterVogn">
    <body use="literal"/>
  </input>
  <output name="OpdaterVogn_Result">
    <body use="literal"/>
  </output>
</operation>

我也会通过我的代码单元给你看我的对象:

代码语言:javascript
复制
<schema elementFormDefault="qualified" targetNamespace="urn:microsoft-dynamics-nav/xmlports/x78001">
  <complexType name="VognType">
    <sequence>
      <element minOccurs="1" maxOccurs="1" name="Kode" type="string"/>
      <element minOccurs="1" maxOccurs="1" name="RegNr" type="string"/>
      <element minOccurs="1" maxOccurs="1" name="Beskrivelse" type="string"/>
      <element minOccurs="1" maxOccurs="1" default="false" name="Spaerret" type="boolean"/>
    </sequence>
  </complexType>
  <complexType name="Vogn" mixed="true">
    <sequence>
      <element minOccurs="1" maxOccurs="unbounded" name="Vogn" type="tns:VognType"/>
    </sequence>
  </complexType>
  <element name="Vogn" type="tns:Vogn"/>
</schema>

无论如何,转到C#之后,我可以将数据转到C#并查看它。现在我想用这个方法更新一个"vogn“。

目前,我的代码如下所示:

代码语言:javascript
复制
        BMGWS ws = new BMGWS();
        Vogn vogne = new Vogn();
        VognType vogn = new VognType();
        ws.UseDefaultCredentials = true;

        ws.SendVogn("BMG 2013", false, ref vogne);

        vogn = vogne.Vogn1[0];
        string kode = vogn.Kode;
        string beskrivelse = vogn.Beskrivelse;
        string regnr = vogn.RegNr;
        bool spaerret = vogn.Spaerret;

        Vogn vogneNy = new Vogn();
        VognType vognNy = new VognType();
        vognNy.Kode = kode; // string value to update
        vognNy.Beskrivelse = beskrivelse; // string value to update
        vognNy.RegNr = regnr; // string value to update 
        vognNy.Spaerret = spaerret; // Bool value to update 

        List<VognType> list = new List<VognType>();
        list.Add(vognNy);
        vogneNy.Vogn1 = list.ToArray();
        vogneNy.Vogn1[0] = vognNy;


        ws.OpdaterVogn("BMG 2013", vogneNy);

我的最后一个方法不起作用,我得到以下错误:

{“Min预期的元素<Kode>出现值:一次。元素接收:<>”}

希望你们能帮我进来..。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-02 14:25:35

我猜你是在Nav用代码单位和XmlPorts。您应该按照下面的链接向下滚动到关于MinOccurs和MaxOccurs的部分,需要在Nav中的XMLPort中具体指定:

http://www.kauffmann.nl/blog/index.php/2011/02/24/how-to-use-xmlports-in-web-services-2/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19116481

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档