Hello,
I am having trouble with passing the XML from SOAP Request to my Codeunit. For this, I am using XMLPort to process and insert a new Customer record, just as a test. I am trying to make the simplest scenario working.
My CODEUNIT:
codeunit 50103 TestAmir
{
[ServiceEnabled]
procedure saveCustVend(_custVendDC: XmlPort CustXMLPort): Text
begin
_custVendDC.Import();
end;
}
The XMLPort file:
xmlport 50010 "CustXMLPort"
{
Caption = 'Customer xml port';
Format = Xml;
UseRequestPage = false;
UseDefaultNamespace = true;
schema
{
textelement(_custVendDC)
{
XmlName = '_custVendDC';
NamespacePrefix = 'd4p1';
tableelement(Customer; Customer)
{
fieldelement(AccountNum; Customer."No.")
{
XmlName = 'AccountNum';
}
fieldelement(Name; Customer.Name)
{
XmlName = 'Name';
}
}
}
}
}
This is the body of the Request in Postman:
<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/TestAmir/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/TestAmir">
<_custVendDC xmlns:d4p1="http://schemas.datacontract.org/2004/07/Dynamics.AX.Application" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d4p1:AccountNum>32659</d4p1:AccountNum>
<d4p1:Name>GLOBAL BENEFITS GROUP INSURANCE</d4p1:Name>
<d4p1:PostalAddress>
<d4p1:PostalAddress>
<d4p1:Country>USA</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 the RESPONSE I get:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">a:System.NullReferenceException</faultcode>
<faultstring xml:lang="en-US">Object reference not set to an instance of an object.</faultstring>
<detail>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Object reference not set to an instance of an object.</string>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
Any help is greatly appreciated.
A.