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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Connecting to a web socket for Integration

(3) ShareShare
ReportReport
Posted on by 42
Greetings Experts!
 
Hi Martin ,
 
Im not able to write the syntax  receive async () Not exactly  able to call System Arraysegment class the compiler gives the error  which is one of the parameters for receiveAsync (), I have tried all possible ways , could you pls provide me the code for RecieveAsync method()  and act accordingly it would actually help me a lot as I have been stuck on this Websocket issue for a while , really having trouble using this System.net classes I’m x++. 
 
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    239,452 Most Valuable Professional on at
    You're going in the right direction; you're already aware of ClientWebSocketOptions.SetRequestHeader(). But don't try to chain the accessors; .NET Interop from X++ doesn't like it. Do something like this:
    ClientWebSocketOptions options = clientWebSocket.Options;
    options.SetRequestHeader('HeaderName', 'value');
    By the way, do it before establishing a connection.
     
    You can use ReceiveAsync() method to receive data.
     
    But don't forget to wait for asynchronous operations to complete. Otherwise you could be trying to send and receive data before a connection was created, or accessing data before it was actually received.
  • MB-14021109-0 Profile Picture
    42 on at
    Hi Martin!
     
    Thanks   a lot  for your response ! I really appreciate it .
    For receiving the response from the server (Web socket ) , I see we have clientWebSocket.ReceiveAsync() but I dont understand how do I give the parameters for this method ,  the method takes Array segment as parameters and Bytes buffer, while using the Array segment class  i get this error , Im sorry if im asking too much but could you please provide me the sample code to receive the response from the web socket and and store it  , having a bit trouble using these classes in x++ but looks fairly simple in .NET
    error.png
  • Martin Dráb Profile Picture
    239,452 Most Valuable Professional on at
    You already have a thread about ArraySegment class, therefore let's not duplicate the discussion here.
     
    Also, I see you change the body of the question it this thread, therefore the discussion here makes no sense, as the answers don't match the new question. Please never do such a thing again; it ruins the usefulness of the forum.

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 622

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 553 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 430

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans