Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Unanswered

SOAP on Business Central Saas

(1) ShareShare
ReportReport
Posted on by 10
Hi experts,
 
I am trying to write a codeunit in BC SaaS to receive the following request:
 
<s:Body>
    <saveCustVend xmlns="http://tempuri.org">
      <DC xmlns:d4p1="http://schemas.datacontract.org/2004/07/Dynamics" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <d4p1:No>1</d4p1:No>
        <d4p1:Name>Test</d4p1:Name>
      </DC>
    </saveCustVend>
  </s:Body>
 
My codeunit looks like this:
 
codeunit 50100 "CustVendWebService"
{
    [ServiceEnabled]
    procedure saveCustVend(var DC: Text[100240]): Text
    var
        CustVendRecord: Record "Customer";
        AccountNum: Text[20];
        Name: Text[100];
 
    begin
 
 
        AccountNum := GetValueFromXML(DC, '<d4p1:AccountNum>', '</d4p1:AccountNum>');
        Name := GetValueFromXML(DC, '<d4p1:Name>', '</d4p1:Name>');
 
        CustVendRecord.Init();
        CustVendRecord."No." := AccountNum;
        CustVendRecord."Name" := Name;
        CustVendRecord.Insert();
 
        MESSAGE('Customer record inserted: %1', AccountNum);
    end;
 
    local procedure GetValueFromXML(XMLText: Text; StartTag: Text; EndTag: Text): Text
    var
        StartPos: Integer;
        EndPos: Integer;
        Value: Text;
        FullStartTag: Text;
    begin
        FullStartTag := StartTag;
        StartPos := StrPos(XMLText, FullStartTag);
        EndPos := StrPos(XMLText, EndTag);
        if (StartPos > 0) and (EndPos > StartPos) then
            Value := CopyStr(XMLText, StartPos + StrLen(FullStartTag), EndPos - StartPos - StrLen(FullStartTag));
        exit(Value);
    end;
}
 
I have published web service, and when I test it in postman, I get this error:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <s:Fault>
            <faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">a:Microsoft.Dynamics.Nav.Service.SOAP.ServiceBrokerException</faultcode>
            <faultstring xml:lang="en-US">Parameter DC in method saveCustVend in service CustVendWebService is null! </faultstring>
            <detail>
                <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Parameter DC in method saveCustVend in service CustVendWebService is null! </string>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>
 
Please help what to do :(

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,904 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,605 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans