I am trying to establish a Web Service for my Business Central Cloud.
I have this SOAP request:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/AmirCustomer/saveCustVend</Action>
<h:CallContext xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="http://schemas.microsoft.com/dynamics/2013/01/datacontracts">
<h:Company i:nil="true" />
<h:Language i:nil="true" />
<h:MessageId i:nil="true" />
<h:PartitionKey i:nil="true" />
</h:CallContext>
</s:Header>
<s:Body>
<saveCustVend xmlns="urn:microsoft-dynamics-schemas/codeunit/AmirCustomer">
<_custVendDC xmlns:d4p1="http://schemas.datacontract.org/2004/07/Dynamics.AX.Application" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d4p1:AccountNum>12345</d4p1:AccountNum>
<d4p1:Active>No</d4p1:Active>
<d4p1:BusinessUnit i:nil="true" />
<d4p1:CostCenter i:nil="true" />
<d4p1:Currency>TRY</d4p1:Currency>
<d4p1:CustClassificationId i:nil="true" />
<d4p1:CustGroup>YD_KURUM</d4p1:CustGroup>
<d4p1:Donem i:nil="true" />
<d4p1:ElectronicAddress />
<d4p1:HospitalCode>MED</d4p1:HospitalCode>
<d4p1:PostalAddress>
<d4p1:PostalAddress>
<d4p1:Country>TUR</d4p1:Country>
<d4p1:County i:nil="true" />
<d4p1:RoleType>Invoice</d4p1:RoleType>
<d4p1:State />
<d4p1:Street>A Delaware, USA Company,Offices Located at 7600 Corporate Center Dr #500, Miami, FL 33126 USA,</d4p1:Street>
</d4p1:PostalAddress>
</d4p1:PostalAddress>
<d4p1:TaxGroup>YI_FTR</d4p1:TaxGroup>
<d4p1:TaxOfficeName i:nil="true" />
<d4p1:VATNum i:nil="true" />
<d4p1:ValueStream i:nil="true" />
<d4p1:VendGroup>Null</d4p1:VendGroup>
</_custVendDC>
</saveCustVend>
</s:Body>
</s:Envelope>
and this is my CODEUNIT:
codeunit 50104 "AmirCustomer"
{
[ServiceEnabled]
procedure saveCustVend(var _custVendDC: Text): Text
var
CustVendRecord: Record "Customer";
ResponseText: Text;
AccountNum: Text[20];
Active: Boolean;
Currency: Text[10];
CustGroup: Text[20];
HospitalCode: Text[10];
IsCustomer: Boolean;
IsVendor: Boolean;
Name: Text[100];
PaymTerm: Text[10];
TaxGroup: Text[10];
text: Text;
xmlDoc: XmlDocument;
Node: XmlNode;
Nmgr: XmlNamespaceManager;
begin
if XmlDocument.ReadFrom(_custVendDC, xmlDoc) then
error('Format(xmlDoc)');
if XmlDoc.SelectSingleNode('//d4p1:AccountNum', Node) then
Node.WriteTo(AccountNum);
//ERROR(AccountNum);
exit(AccountNum);
end;
}
For now, I would just like to be able to pass AccountNum and other nodes to my codeunit for further processing…
With this current code I get the error:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">a:System.Reflection.TargetInvocationException</faultcode>
<faultstring xml:lang="en-US">Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.</faultstring>
<detail>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Exception has been thrown by the target of an invocation.</string>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
Any help is very much appreciated.
Thanks in advance,
V.