web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Consume Web service on Susiness Central Saas

(1) ShareShare
ReportReport
Posted on by 16
Dear experts,
 
I am trying to make web service on Business Central SAAS to read this request:
 <s:Body>
    <saveCustVend xmlns="http://tempuri.org">
      <_custVendDC xmlns:d4p1="http://schemas.datacontract.org/2004/07/Dynamics" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <d4p1:AccountNum>1</d4p1:AccountNum>
        <d4p1:Name>Test</d4p1:Name>
      </_custVendDC>
    </saveCustVend>
  </s:Body>
 
I made the following codeunit and exposed it as a webservice:
 
codeunit 50100 "CustVendWebService"
{
    [ServiceEnabled]
    procedure saveCustVend(var _custVendDC: Text[100240]): Text
    var
        CustVendRecord: Record "Customer";
        AccountNum: Text[20];
        Name: Text[100];
 
    begin
 
        AccountNum := GetValueFromXML(_custVendDC, '<d4p1:AccountNum>', '</d4p1:AccountNum>');
        Name := GetValueFromXML(_custVendDC, '<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 ested this in the postman and got this response:
<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 _custVendDC in method saveCustVend in service CustVendWebService is null! </faultstring>
            <detail>
                <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Parameter _custVendDC in method saveCustVend in service CustVendWebService is null! </string>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>
 
What am I doing wrong?
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    100,001 Super User 2026 Season 1 on at

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,875 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 926 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 642 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans