Twilio Websockets: retrieve stream's payload only - websocket

According to this guide ( https://www.twilio.com/docs/voice/tutorials/consume-real-time-media-stream-using-websockets-python-and-flask ) you can consume a real-time Media Stream using WebSockets.
However, instead of creating a stream's fork like this:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Start>
<Stream url="wss://yourdomain.ngrok.io/media" />
</Start>
<Dial>+15550123456</Dial>
</Response>
how would you only receive the stream's payload via websocket without specifying <Dial></Dial> endpoint. If you remove <Dial></Dial> tag there, call ends as <Stream /> is asynchronous and there is no following event to be handled.
Would you replace <Dial></Dial> with some other tag?

Related

Twilio Media Streams - Websocket handshake error 31920

I've created a Bot published to Azure that has the following channels: Direct Line, Direct Line Speech, SMS channels, and WebChat. I've turned on Websockets, and Enabled Streaming Endpoint.
I can test the webchat on the Azure portal and it works correctly. I can use the Bot Emulator and the Voice Assistant Client which uses Websockets and it works correctly on both.
I have a web app that takes in the webhook from Twilio, calls out to the direct line endpoint with the DL secret and retrieves a token and a wss:// url for the websocket. This is passed back to Twilio:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Start>
<Stream name="Socket_Stream" url="wss://directline.botframework.com/v3/directline/conversations/Eurh9C4N2q8F9vPVGZrLAG-j/stream?watermark=-&t=ew0KICAiYWxnIjogIlJTMjU2IiwNCiAgI...." />
</Start>
<Say>Webhook and socket information returned</Say>
</Response>
Twilio receives the packet, says, "Webhook and socket information returned" then promptly hangs up.
This is the error I'm receiving from Twilio
I made sure that the server is capable of TLS1.2.
I'm officially stuck. Any ideas on what I can check on?
Thanks

Get the details of Listeners on Azure Relay

I am using Azure ServiceBus Relay and although I am able to fetch the count of the current listeners, I want to know the details of those listeners as well. For example, their id or address. An attribute that I can use to access or target that particular listener.
As of now I am sending a GET request to :
https://{our relay}.servicebus.windows.net/
with a SAS token as header and returned object is:
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text">Publicly Listed Services</title>
<subtitle type="text">This is the list of publicly-listed services currently available.</subtitle>
<id>uuid:85ad7592-cecf-4f31-bef2-4bb7f5cea444;id=2185</id>
<updated>2019-12-17T10:27:55Z</updated>
<generator>Service Bus 1.1</generator>
</feed>

Sending SOAP Header along with main body to SOAP server using Spring Boot

As a SOAP newbie I am following the same tutorial as given in Spring boot - Server did not recognize the value of HTTP Header SOAPAction. The tutorial can be found in https://howtodoinjava.com/spring-boot/spring-soap-client-webservicetemplate/amp/
Currently I am able to send the SOAP payload with the request needed. The server is responding to say I have not authenticated.
I therefore am trying to send the SOAP header with authentication detail along with this SOAP payload. See below examples.
Firstly, I have successfully managed to get the tutorial working. The request was sent with SOAP Action and response received.
Sent request [SaajSoapMessage {http://server.windeed.co.za/windeedengine/}CheckDeedsOfficeStatus]
The response is that I have not authenticated/sent authentication details correctly. I therefore created the Authentication Object with all the necessary details in order to marshall and make part of the SOAP message.
I tried the below:
ObjectFactory of = new ObjectFactory();
WinDeedCredentials cred = of.createWinDeedCredentials();
cred.setUsername("Test");
cred.setPassword("Test123");
cred.setCompany("COMPANY");
cred.setRequester("SOAP");
CheckDeedsOfficeStatus cdo = of.createCheckDeedsOfficeStatus();
CheckDeedsOfficeStatusResponse dr = (CheckDeedsOfficeStatusResponse)sc.callWebService(cdo,"http://server.windeed.co.za/windeedengine/CheckDeedsOfficeStatus");
The goal is to achieve this:
POST /windeedengine3/client.asmx HTTP/1.1
Host: server.windeed.co.za
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://server.windeed.co.za/windeedengine/CheckDeedsOfficeStatus"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<WinDeedCredentials xmlns="http://server.windeed.co.za/windeedengine/">
<Username>string</Username>
<Password>string</Password>
<Company>string</Company>
<Requester>string</Requester>
</WinDeedCredentials>
</soap:Header>
<soap:Body>
<CheckDeedsOfficeStatus xmlns="http://server.windeed.co.za/windeedengine/" />
</soap:Body>
</soap:Envelope>
Currently, with the missing Authentication details, I am told I haven't authenticated correctly.
The expected result is the correct response from the server: Online or Offline. What is the correct way?
I forgot to even revisit this topic. The problem was solved but I do not have the details immediately with me and need to travel to access them.
Prior to making the webservice call => sc.callWebService, it is important to inject the SOAP header details. I injected the xml header from SOAP UI into the code. Viola! It worked. Previously the MarshallSendAndReceive method was used with only the SoapActionCallback method. If I recall, I modified this to use WebServiceMessageCallback with an explicit definition of the xml header prior to making the webservice call.

EWS writing calendar event to user's calendar throws "The specified folder could not be found in the store."

I am attempting to create a meeting for a user with a room using the EWS api. When I send the below SOAP request, I receive the error "The specified folder could not be found in the store.". Is there anything wrong with the SOAP request, or is there anything that needs to be changed on the Exchange server?
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages">
<SOAP-ENV:Header>
<ns1:RequestServerVersion Version="Exchange2007"/>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns2:CreateItem SendMeetingInvitations="SendToAllAndSaveCopy">
<ns2:SavedItemFolderId>
<ns1:DistinguishedFolderId Id="calendar">
<ns1:Mailbox>
<ns1:EmailAddress>[useremail#website.com]</ns1:EmailAddress>
</ns1:Mailbox>
</ns1:DistinguishedFolderId>
</ns2:SavedItemFolderId>
<ns2:Items>
<ns1:CalendarItem>
<ns1:ItemClass>IPM.Appointment</ns1:ItemClass>
<ns1:Subject>Test</ns1:Subject>
<ns1:Sensitivity>Normal</ns1:Sensitivity>
<ns1:Importance>Normal</ns1:Importance>
<ns1:Start>2018-12-29T06:49:00+00:00</ns1:Start>
<ns1:End>2018-12-29T06:50:00+00:00</ns1:End>
<ns1:RequiredAttendees>
<ns1:Attendee>
<ns1:Mailbox>
<ns1:Name>Test user</ns1:Name>
<ns1:EmailAddress>[useremail#website.com]</ns1:EmailAddress>
<ns1:RoutingType>SMTP</ns1:RoutingType>
</ns1:Mailbox>
</ns1:Attendee>
</ns1:RequiredAttendees>
<ns1:Resources>
<ns1:Attendee>
<ns1:Mailbox>
<ns1:EmailAddress>[roomemail#website.com]</ns1:EmailAddress>
<ns1:RoutingType>SMTP</ns1:RoutingType>
</ns1:Mailbox>
</ns1:Attendee>
</ns1:Resources>
</ns1:CalendarItem>
</ns2:Items>
</ns2:CreateItem>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
That error indicates you don't have rights to the underlying calendar your trying to create the Appointment on. You would probably be better using EWS Impersonation in the senerio you describing as that will allows you to create the Appointment as the user (instead of On Behalf of) see https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-configure-impersonation
With you code you should be using Exchange2007
<SOAP-ENV:Header>
<ns1:RequestServerVersion Version="Exchange2007"/>
</SOAP-ENV:Header>
the RTM version of Exchange had a different Id format so i would suggest at least Exchange2007_SP1 or use the version you have the code working against see https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/ews-schema-versions-in-exchange

Ruby and MS Dynamics CRM Authentication

I'm attempting to access MS CRM that's exposed via IFD, and I'm having authentication issues.
The SOAP endpoint is behind NTLM, which I've been able to access. The problem is, I'm getting 401 responses when passing requests like the following:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Execute xmlns="http://schemas.microsoft.com/crm/2007/CrmDiscoveryService">
<Request xsi:type="RetrieveCrmTicketRequest">
<OrganizationName>#{CRM_CONFIG[:org_name]}</OrganizationName>
<UserId>#{CRM_CONFIG[:username]}</UserId>
<Password>#{CRM_CONFIG[:password]}</Password>
</Request>
</Execute>
</soap:Body>
</soap:Envelope>
Is there any way of debugging this on the server? Any logs I can check to get a more meaningful error message?
I'm also getting a 401 when attempting the following request (this time to the CrmService.asmx endpoint):
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">
<soap:Header>
<CrmAuthenticationToken xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">
<AuthenticationType xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">2</AuthenticationType>
<OrganizationName xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">#{CRM_CONFIG[:org_name]}</OrganizationName>
<CallerId xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">#{TOUCH}</CallerId>
</CrmAuthenticationToken>
</soap:Header>
<soap:Body>
<RetrieveMultiple xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">
<query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\">
<q1:EntityName>contact</q1:EntityName>
</query>
</RetrieveMultiple>
</soap:Body>
</soap:Envelope>
Ok, the problem was a misunderstanding of the setup:
When using NTLM, Active Directory authentication is used, meaning that the CrmAuthenticationToken should have looked like this:
<CrmAuthenticationToken xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">
<AuthenticationType xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">0</AuthenticationType>
<OrganizationName xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">#{CRM_CONFIG[:org_name]}</OrganizationName>
</CrmAuthenticationToken>
Note that the CallerId element isn't needed.
You can turn on server side tracing by hand or with a tool. Look for trace files in C:\Program Files\Microsoft Dynamics CRM\Trace. For easy trace file viewing I recommend using CRM Trace Log Viewer.
There are lots of articles about how to call Dynamics CRM web services from JavaScript. I can imagine those will come in handy.
In my experience, two more tools will also come handy, Fiddler to trace http requests and responses and SoapUI for web service testing and debugging.
Also note, that Dynamics CRM 2011 will come with REST based services in addition to SOAP based, which will greatly simplify CRM web service usage from non-.net products.

Resources