RE: Sending post request in java

2005-09-23 Thread Spyros Sakellariou



Well 
although I have never tested my client for SMS but for Push Proxy, one 
difference that I see with my code(using Sockets but the principle is the 
same)is the "Content-Type" parameter.
Try 
setting it to "application/xml" instead of "text/xml"

One 
more problem that I had is that all new lines have to end with \r\n and not just 
\n or \r

If all 
else fails you will need to use Ethereal (it is open source and you can get it 
from http://www.ethereal.com/) to make 
sure that the Content-Length of your post request is absolutely correct. 
Kannel is very sensitive to wrong content lengths.

Here 
is some code that succesfully sends a POSTrequest to kannel WAP 
Push. I think that if youchangethe 
code to your needsyou should make it work for SMS as well (sorry is in 
sockets not HttpClient - can't seem to find any old code with HttpClient 
:(

===
import 
java.net.*;import java.io.*;/** 
PushMeSocket.java**/

public 
class PushMeSocket { URL PPGurl; 
String PPG_URL; String charen = 
"UTF-8"; String hostName = 
"is-3052"; int port = 39898; String 
path = "/wappush"; InetAddress 
inetAddress; Socket socket; String 
data;  /** Creates a new instance of 
PushMeSocket */ public PushMeSocket() 
{ this.PPG_URL = "http://is-3052:39898/wappush"; 
 try { 
 
 inetAddress = 
InetAddress.getByName(hostName); 
socket = new 
Socket(inetAddress,port); 
 } catch (Exception e) 
{ 
e.printStackTrace(); 
} }  
/** * @param args the command line 
arguments */ public static 
void main(String[] args) { 
 PushMeSocket push = new 
PushMeSocket(); StringBuffer 
xmlBuffer = new StringBuffer(); 
 char 
tmp; int 
readTmp; try 
{ 
BufferedReader xmlFile = new BufferedReader(new 
FileReader(args[0])); 
while 
((readTmp=(char)xmlFile.read())!=65535){ 
tmp = (char) readTmp; 
 
if (readTmp == 10) 
{ 
xmlBuffer.append('\r'); 
} 
xmlBuffer.append(tmp); 
 
} 
xmlFile.close(); 
 push.data 
= ""> } catch 
(Exception e) 
{ 
e.printStackTrace(); 
} 
 
System.out.println(push.PushMessage(push.data, 
"multipartboundary")); } 
  public String PushMessage(String 
XMLDoc, String MultiPartSeperator) 
{ 
 
 StringBuffer replyString = new 
StringBuffer(); StringBuffer 
headerString = new StringBuffer(); 
try { 
 
BufferedWriter sendXMLStream = new BufferedWriter (new 
OutputStreamWriter(socket.getOutputStream(),this.charen)); 
BufferedReader ppgReply = new BufferedReader(new 
InputStreamReader(socket.getInputStream(),this.charen)); 
headerString.append("POST " + this.path + " 
HTTP/1.1\r\n"); 
headerString.append("Host: " + this.hostName + 
":"+this.port+"\r\n"); 
headerString.append("Content-Type: multipart/related; 
boundary="+MultiPartSeperator+"; 
type=\"application/xml\"\r\n"); 
 
headerString.append("Content-Length: " + (XMLDoc.getBytes().length) 
+"\r\n\r\n"); 
sendXMLStream.write(headerString.toString()); 
sendXMLStream.write(XMLDoc); 
System.out.println("+"); 
System.out.println(headerString.toString()); 
System.out.println(XMLDoc); 
System.out.println("+"); 
 
sendXMLStream.flush(); 


 
 
 char[] 
tmp = new 
char[5000]; 
System.out.println("Ready to receive reply 
"); 
 
ppgReply.read(tmp); 
replyString.append(tmp); 


 
ppgReply.close(); 
sendXMLStream.close(); } catch 
(Exception e) 
{ 
e.printStackTrace(); 
} 
 return 
replyString.toString(); } 
}=

Hope 
it helps,

Spyros


  -Original Message-From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]On Behalf Of Gelvis 
  SequeraSent: Thursday, September 22, 2005 6:21 PMTo: 
  users@kannel.orgSubject: Re: Sending post request in 
  java
  I used the HttpCLient, and i couldn't resolve the problem
  
  here is a piece of code:
  case 
  Request.POST:methodP 
  = new 
  PostMethod(url);methodP.setRequestHeader("Content-type", 
  "text/xml");methodP.setRequestBody(request.getRequest()); 
  client.executeMethod(methodP);response = 
  methodP.getResponseBodyAsString();break;
  
  do i have to set some attribute on the PostMethod is there any tip? 
  
  
  Thanks .. 
  On 9/22/05, Spyros 
  Sakellariou [EMAIL PROTECTED] wrote: 
  

I had the same problems 
trying to send Push Mesages from Java using the 
HttpUrlConnection.
Checking with Ethereal I 
found out that the HttpUrlConnection object breaks the request into two 
packets and that probably confuses Kannel.
I tried using sockets (more 
work of course) and everything worked well.
Also the HttpClient library 
from Apache Commons works well with kannel and ismuch easier to use 
than HttpUrlConnection.
Just don't use 
theHttpUrlConnection object.


Determining Success or Failure

2005-09-23 Thread Brent Goldspring












Hello all,



We are using Kannel with a GSM modem: what is the
quickest and easiest way (for an application) to determine if the modem sent
the SMS or not? I do not need delivery reports, just wether the modem said,
“OK” or “Error”. Am I going to have to run a web-server and use dlr-url etc? I
could probably parse the bearerbox access log, but that is a bit ugly, clunky
and will get really slow when the log gets full.



Regards,

Brent














Re: Determining Success or Failure

2005-09-23 Thread Linkas




Brent Goldspring wrote:

  
  
  
  
  
  
  Hello all,
   
  We are using Kannel
with a GSM modem: what is the
quickest and easiest way (for an application) to determine if the modem
sent
the SMS or not? I do not need delivery reports, just wether the modem
said,
“OK” or “Error”. Am I going to have to run a web-server and use dlr-url
etc? I
could probably parse the bearerbox access log, but that is a bit ugly,
clunky
and will get really slow when the log gets full.
   
  
  
  

DLR url is quick, easy and no time consuming for you as soon as you
have a webserver running, but can also implement it as a simple
listening port 80 on that machine.
Don't use dlr-mask 31 but a simple 28 (error+sent to smsc+queued to
smsc)
Parsing logs it's a very bad idea I think, it's really better than to
modify the C code of the log writing snip.





Decoding a sms message

2005-09-23 Thread Morten Bruun
Hi all,

I'm trying to send wap-cir messages through Kannel. This is done through the PPG with something like this

POST /cgi-bin/wap-push.cgi HTTP/1.0 
Content-Type: multipart/related; type=application/xml; 
boundary=EndOfOneEntity 
User-Agent: 
Java1.4.2_05 
Host: 
pn.attwireless.net:9002 
Accept: text/html, 
image/gif, image/jpeg, *; q=.2, */*; q=.2 
Connection: Keep-Alive 
Content-Length: 502 

--EndOfOneEntity 

Content-Type: 
application/xml; charset=UTF-8 

?xml 
version=1.0? 
!DOCTYPE pap PUBLIC 
-//WAPFORUM//DTD PAP 1.0//EN 
http://www.wapforum.org/DTD/pap_1.0.dtd 
pap 
push-message 
push-id=1031290fab11944511621/WV Push 
address 
address-value=WAPPUSH=+4523229536/TYPE=[EMAIL PROTECTED]/ 

/push-message 
/pap 

--EndOfOneEntity 

Content-Type: 
application/vnd.wv.csp.cir 
X-WAP-Application-Id: x-wap-application:wv.ua 


WVCI 1.1 QGNUNEUAUK 

--EndOfOneEntity--

The smsc is set to 'emi'. In bearerbox-access.log this is logged:

2005-09-23 12:20:48 Sent SMS [SMSC:smsc333] [SVC:ppg] [ACT:] [BINF:]
[from:1234] [to:+45] [flags:-1:1:-1:-1:0]
[msg:120:0006316170706C
69636174696F6E2F766E642E77762E6373702E63697200A96C6962772D7065726C2F352E3639008DC4C3935741502D4170706C69636174696F6E2D49643A20782D7761702D
6170706C69636174696F6E3A77762E75610D0A0D0A5756434920312E312051474E554E455541554B0D0A] [udh:7:0605040B8423F0]

Can anyone point me to a document that will help me decode/understand the binary(?) message above?

Kind regards,
Morten



Re: Kannel under cygwin - missing crypto library?

2005-09-23 Thread Wilfried Goesgens
On Thu, Sep 22, 2005 at 05:23:57PM +0100, Jim Hatfield wrote:
 I've set up Kannel on Linux with no problem. Today I tried
 to set it up under Cygwin (which I've no previous experience of).
 
 I did a Cygwin install, accepting the defaults for everything.
 
 I installed the Kannel binaries in to /usr/local/kannel, no problem.
 
 When I try to run any of the executables, I get:
 
 This application has failed to start because cygcrypto.dll was not
 found. Re-installing the application may fix this problem.
 
 Indeed there is no cygcrypto.dll anywhere under c:\cygwin, though
 there is a cygcrypt-0.dll under c:\cygwin\bin. I've looked in the
 Cygwin installer and it's not obvious where to get this from. Any
 clues would be gratefully received!
 
 
this library should be in the openssl package. install it using the cygwin 
setup tool.

Wilfried Goesgens



Re: Sending post request in java

2005-09-23 Thread Wilfried Goesgens
On Thu, Sep 22, 2005 at 01:51:30PM +0300, Spyros Sakellariou wrote:
breaks the request into two packets and that probably confuses Kannel.
as of both, kannel and your java programm use the kernel tcp/ip stack this
is most likely not the case.
It is the content wich you should have a look at. Capture it using netcat
as server instead ov kannel, and use netcat afterwards to test kannel.
please recompile kannel with the flags I gave you, and post the complete
Panic stack trace again.

Wilfried Goesgens



RE: Sending post request in java

2005-09-23 Thread Spyros Sakellariou
Well  Ethereal shows two packets when I use the HttpUrlConnection object and
only one when I use java sockets or other utility objects such as the apache
commons client.

The problem was fixed when I used sockets.
So what I am saying is that probably this is not a Kannel problem but a Java
problem, since the way to fix it for me was to stay away from the
HttpUrlConnection object.

I posted some Java code before that it worked for me for sending Push
requests to kannel so I think with a few modifications Gelvis can use it for
sendind SMS requests as well.
I experienced the same problems he describes when I used the
HttpUrlConnection object.


Spyros


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of
Wilfried Goesgens
Sent: Friday, September 23, 2005 11:24 AM
To: users@kannel.org
Subject: Re: Sending post request in java


On Thu, Sep 22, 2005 at 01:51:30PM +0300, Spyros Sakellariou wrote:
breaks the request into two packets and that probably confuses Kannel.
as of both, kannel and your java programm use the kernel tcp/ip stack this
is most likely not the case.
It is the content wich you should have a look at. Capture it using netcat
as server instead ov kannel, and use netcat afterwards to test kannel.
please recompile kannel with the flags I gave you, and post the complete
Panic stack trace again.

Wilfried Goesgens





RE: Determining Success or Failure

2005-09-23 Thread Alejandro Ramírez












Why dont you give SQLBOX a try it has
helped me a lot!



Alejandro



-Mensaje original-
De: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] En nombre
de Brent Goldspring
Enviado el: Jueves, 22 de
Septiembre de 2005 11:55 p.m.
Para: users@kannel.org
Asunto: Determining Success or
Failure







Hello all,



We are using Kannel
with a GSM modem: what is the quickest and easiest way (for an application) to
determine if the modem sent the SMS or not? I do not need delivery reports,
just wether the modem said, OK or Error. Am I going to have to run a
web-server and use dlr-url etc? I could probably parse the bearerbox access
log, but that is a bit ugly, clunky and will get really slow when the log gets
full.



Regards,

Brent