Main Site Documentation

Cellular Radio - Post to WCF Service


#1

Hi,
I am trying to make a post request to a WCF service which saves the data. Unfortunately I am getting a 405 - Method Not Allowed error. I was able to execute a get request successfully so the network settings are OK. If I post the request from fiddler it works. Here is the code:


returnedState = cellularRadio.SendATCommand("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");

            returnedState = cellularRadio.SendATCommand("AT+SAPBR=3,1,\"APN\",\"******\"");

            returnedState = cellularRadio.SendATCommand("AT+SAPBR=3,1,\"USER\",\"******\"");

            returnedState = cellularRadio.SendATCommand("AT+SAPBR=3,1,\"PWD\",\"******\"");

            returnedState = cellularRadio.SendATCommand("AT+SAPBR=1,1");

            returnedState = cellularRadio.SendATCommand("AT+HTTPINIT");

            returnedState = cellularRadio.SendATCommand("AT+HTTPPARA=\"CID\",1");

            //returnedState = cellularRadio.SendATCommand("AT+HTTPPARA=\"URL\",\"http://www.google.com\"");

            returnedState = cellularRadio.SendATCommand("AT+HTTPPARA=\"URL\",\"http://******:8080\"");

            string requestString = "POST /TestService.svc HTTP/1.1\r\n";
            requestString += "Content-Type: text/xml; charset=utf-8\r\n";
            requestString += "SOAPAction: \"http://tempuri.org/ITestService/TestMethod\"\r\n";
            requestString += "Host: ******:8080\r\n";
            //requestString += "Content-Length: 194\r\n";
            requestString += "Expect: 100-continue\r\n";
            requestString += "Accept-Encoding: gzip, deflate\r\n";
            requestString += "Connection: Keep-Alive\r\n";
            requestString += "\r\n";
            requestString += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><TestMethod xmlns=\"http://tempuri.org/\"><parameters>Test from GHI module.</parameters></TestMethod></s:Body></s:Envelope>\r\n";

            returnedState = cellularRadio.SendATCommand("AT+HTTPDATA=" + requestString.Length + ",3000");

            returnedState = cellularRadio.SendATCommand(requestString);

            returnedState = cellularRadio.SendATCommand("AT+HTTPACTION=1");

            returnedState = cellularRadio.SendATCommand("AT+HTTPREAD");

            returnedState = cellularRadio.SendATCommand("AT+HTTPTERM");

Any help will be greately appreciated.

Thanks


#2

You need to make sure the modem is setup to actually be attached to the GPRS network. This means it actually has an IP address and can serve and client to servers. Check out all the info here for that setup:
http://www.ghielectronics.com/community/forum/topic?id=11774&page=2

One of my next steps in a project is to connect to a server via ftp or your manor to dump data.


#3

Thank you for your help, logictechs.
I am still not sure whether attaching to the GPRS network with your code is making any difference because I changed the code to use a public service and doing it both ways I receive 302. What I found is that sending the request string is returning InvalidCommand. I changed the code to do it with SendTcpData but it is returning the same error code. This should be because I am using the default driver and SendTcpData is calling. SendATCommand. Is there another way of sending just the data or I have to switch to some other driver or create my own? I will update when I make progress.


#4

Instead of adding the cellular module in the designer, I started adding the driver files so I could change them on the fly in my own application. If found that there are different versions of the AT command PDF out there. You need to get the one that is for the firmware version in your modem. V1.03 PDF allowed me to figure out the starting a server. Perhaps your using a different version than your firmware for the commands?