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

Notifications

Announcements

No record found.

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 40
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
    237,829 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
    40 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
  • Martin Dráb Profile Picture
    237,829 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 512 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 291 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans