所以,如果我做错了什么,请容忍我。我一直试图从C#更新Nav中的一些数据,但是无论我做什么,我都会得到错误:
我的代码单元如下所示,这是我需要用来更新的方法:
<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>我也会通过我的代码单元给你看我的对象:
<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“。
目前,我的代码如下所示:
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>出现值:一次。元素接收:<>”}
希望你们能帮我进来..。
发布于 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/
https://stackoverflow.com/questions/19116481
复制相似问题