Jump to content

Trying to learn/use CSTA


Bill H
 Share

Recommended Posts

I have been trying to use CSTA to the PBX not to the phones.

 

I followed the examples as best as I could and when I POST to the PBX this is what I receive from the Logfile:

 

 

[8] 2011/05/18 09:59:33: SOAP: Request from IP address 192.168.111.123 without a session

 

[5] 2011/05/18 09:59:33: Receive SOAP request via HTTP interface

 

<?xml version="1.0" encoding="UTF-8"?>

<StartApplicationSession xmlns="http://www.ecma-international.org/standards/ecma-354/appl_session/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<applicationInfo>

<applicationID>My App</applicationID>

<applicationSpecificInfo>

<SessionLoginInfo xmlns="http:// www.pbxnsip.com/schemas/csta/login">

<userName>41</userName>

<password>12345</password>

<domain>localhost</domain>

<sessionCleanupDelay>60</sessionCleanupDelay>

</SessionLoginInfo>

</applicationSpecificInfo>

</applicationInfo>

<requestedProtocolVersions>

<protocolVersion>http://www.ecma-international.org/standards/ecma-323/csta/ed2</protocolVersion>

<protocolVersion>http://www.ecma-international.org/standards/ecma-323/csta/ed3</protocolVersion>

<protocolVersion>http://www.ecma-international.org/standards/ecma-323/csta/ed4</protocolVersion>

<protocolVersion>http://www.ecma-international.org/standards/ecma-323/csta/ed5</protocolVersion>

<protocolVersion>http://www.ecma-international.org/standards/ecma-323/csta</protocolVersion>

</requestedProtocolVersions>

<requestedSessionDuration>180</requestedSessionDuration>

</StartApplicationSession>

 

[5] 2011/05/18 09:59:33: SOAP: Unrecognized type StartApplicationSession, expect envelope

 

 

I am using VB6 with XMLHTTP to POST.

 

It says that I am sending in a SOAP Request, but I am not sure why.

 

I can post the source code if needed.

 

Thanks...

Link to comment
Share on other sites

Are you sure you sent the exact same xml from the example, except for the login data? Can you post a pcap trace with the request and reply?

 

I think the trouble in my Post/Header Method.

 

There are no examples when Posting to the PBX. I see Posting to the phone, but I want to go to the PBX.

 

I tried another Post way and I get this in return:

 

HTTP/1.1 302 Moved Temporarily

Location: login.htm

Content-Type: text/html

Cache-Control: no-cache

Cache-Control: no-store

Set-Cookie: session=848j1vjhpscwlorsjszk

Content-Length: 156

 

<html><head>

<title>Redirect</title>

</head><body>

If you don't get redirected automatically, please click <a href="login.htm">here</a>

</body></html>

 

Pcap Attached

 

Thanks again for your response...

csta1.zip

Link to comment
Share on other sites

Try removing the POST line and Content-type header. Here is a trace of a working example and a small test application you can run in python, I hope it helps:

 

test5.zip test3.zip

 

OK I am now able to communicate with the PBX.

 

The main trouble was that the characters preceding the XML were affecting my display of the received data.

 

Here they are '\x00\x00\x01\xc0l ve<?xml version="1.0" encoding="UTF-8"?>

 

Once I removed them, I could see the data.

 

Thank you for your assistance.

 

Bill H

Link to comment
Share on other sites

  • 3 weeks later...

here is code to get others heading in the right direction with vb.net. you may not be able to use it verbatim.

 

 

 

   Public Sub CSTAPost()

       Try
           Dim PBX_Port As Int32 = 80
           Dim PBX_IPAddress As IPAddress = IPAddress.Parse("192.168.1.10")

           Dim TCP_Client As New TcpClient()
           Dim TCP_Encoder As New UTF8Encoding



           TCP_Client.Connect(PBX_IPAddress, PBX_Port)


           Dim TCP_Stream As NetworkStream = TCP_Client.GetStream

           Dim bytes(TCP_Client.ReceiveBufferSize) As Byte
           Dim responseData As String

           '  Dim aresponse As String

           Dim message As String = "<?xml version=""1.0"" encoding=""UTF-8""><StartApplicationSession xmlns=""http://www.ecma-international.org/standards/ecma-354/appl_session/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""><applicationInfo> <applicationID>My App</applicationID> <applicationSpecificInfo> <tns:SessionLoginInfo xmlns:tns=""http://www.pbxnsip.com/schemas/csta/login""> <tns:userName>40</tns:userName> <tns:password>40</tns:password>40<tns:domain>localhost</tns:domain> <tns:sessionCleanupDelay>60</tns:sessionCleanupDelay> </tns:SessionLoginInfo> </applicationSpecificInfo></applicationInfo><requestedProtocolVersions> <protocolVersion>http://www.ecma-international.org/standards/ecma-323/csta/ed3</protocolVersion> <protocolVersion>http://www.ecma-international.org/standards/ecma-323/csta/ed4</protocolVersion> <protocolVersion>http://www.ecma-international.org/standards/ecma-323/csta/ed5</protocolVersion></requestedProtocolVersions><requestedSessionDuration>1800</requestedSessionDuration></StartApplicationSession>"
           Dim data As Byte() = TCP_Encoder.GetBytes(message)


           TCP_Stream.Write(data, 0, data.Length)
           '  MsgBox(m_stream.DataAvailable)

           TCP_Stream.Read(bytes, 0, CInt(TCP_Client.ReceiveBufferSize))

           ' Output the data received from the host to the console.  
           responseData = Encoding.ASCII.GetString(bytes)
           CSTAResponseData = responseData




           CSTAResponseData = Mid(responseData, InStr(responseData, "<sessionID>"), 45)



           ' Close everything.  
           TCP_Stream.Close()
           TCP_Client.Close()

       Catch e1 As ArgumentNullException
           'Console.WriteLine("ArgumentNullException: {0}", e)  
           MsgBox("argument null " & e1.ToString)
       Catch e1 As SocketException
           ' Console.WriteLine("SocketException: {0}", e)  
           MsgBox("socket exp" & e1.ToString)
       End Try
   End Sub

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...