I am getting special characters(?????) on my mobile when I send arabic text through JAVA Webservice. Below is the whay how I implemented.
Webservice Client and Test program is on my windows PC and I am running from Eclipse whose char set is ISO-8859-1.
In my Test Program I am encoding (using URLEncoder) the Arabic String to ISO-8859-6.
WebService Host is Installed on Linux server. Here I am converting the encoded string to bytes. Then I am forwading this request to java service over TCP IP. This service is responsible to send SMS.
In this Java service I am decoding with same encryption as above and posting to SMS provider.
Implementation
/**
* Arabic Implementation is as below
**/
String message= arabictext;
message=URLEncoder.encode(message,"ISO-8859-6");
sendMessage(message,uername,password); ///webservice call
Web Service Host coding:
sendMessage(p_message,username,password){
byte[] request = message.getbytes();//tried by passing character set
Tcserver.post(request);//posting the request to java client
}
Note: Both Webservice Host and java client are hosted on same physical server.
Java Client :
sendSMS(p_message){
message =URLDecoder.decode(p_message,"ISO-8859-6");//send message to mobile provider.
sendmessagetoProvider(message);
}
when I ran TCPViewer on my PC I am seeing special characters. Any idea how to fix this issue.
I think that the problem is somewhere into your sendmessagetoProvider as well as in usage for URLEncoder and URLDecoder.
When you are sending message you probably have to encode it. You are calling decode at client side instead. BTW IMHO this is the reason for "special characters" you receive.
So, first take a look on your API specification. What is method sendmessagetoProvider expecting? Probably you do not have to encode the string as URL? Probably it just supports Unicode or you have to provide the encoding when you are calling client? Then fix you code accordingly.
Good luck.
Related
I have a requirement where I intend to build a tool to scan the email contents including the attachments. The email servers is either going to be SendMail or z/OS Communication Server, both support SMTP. The sever is not Miscrosoft implementation so MAPI or Outlook API is not there into picture. The tool would be Java based code and basically need to look for contents that are not-permitted based on some rules. What are my options here? There is the possibility of using a proxy server but we are looking for a more direct approach.
The z/OS Communication Server SMTP implementation has a built-in "exit" capability - see http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/F1A1B4B0/30.3?DT=20110609204120#HDRWQ1299.
The exit is called for just about any SMTP activity and it can examine, change or reject just about anything based on the rules you establish. It is generally written in IBM Assembler Language, but there's no reason you couldn't have a thin assembler layer that passes data to a Java app using whatever protocol you like (say, a pipe or a socket).
There are many little details to handle, such as character encoding (EBCDIC vs. ASCII or UTF-8, for example) plus weeding out attachments from email content. But using the exit preserves all the z/OS specific features of IBM's SMPT server without trying to recreate any of that yourself.
Good luck!
I have a basic Netty server (From the tutorial) (http://netty.io/wiki/user-guide-for-4.x.html), and it recieves the requests from the client, but how would I go about sending a string to the client?
For example, on a normal Minecraft server, you specify the "MOTD" in the configuration file, and when a client pings it from the server list, it will display that string. I need to do the same thing, but from my server code.
If you wish to send the MoTD to the client you will have to figure out what gets sent in terms of protocol and data.
For example in the most basic form the data sent could be 1 byte for action (display motd) and then variable length for a string.
If I had to find out how to send this I would go look at the open-source bukkit repositories or the Minecraft Decompiled Code Repository to find out the way to do it myself.
Update:
Upon looking at the code it seems that also Minecraft uses Netty, so this plays in your advantage in terms of understanding it. Unfortunately the code is unofficially decompiled and thus obfuscated.
Update 2:
I believe the class you should inspect is
net.minecraft.server.PacketStatusOutServerInfo
and the data sent appears to be JSON generated by the ServerPing class.
You can also check out Minecraft Protocol (specifically Ping); a place where modders can find an explanation of protocol & encryption.
This handler shows the sending of the MOTD:
https://github.com/Bukkit/mc-dev/blob/c1627dc9cc7505581993eb0fa15597cb36e94244/net/minecraft/server/LegacyPingHandler.java
It just happens to be that the MOTD handling goes on line number 69: https://github.com/Bukkit/mc-dev/blob/c1627dc9cc7505581993eb0fa15597cb36e94244/net/minecraft/server/LegacyPingHandler.java/#L69
When the channel receives the ping packet, it encodes the response into a ByteBuf and writes it back out of the channel.
Note that there are a few decompilation errors on the file - ignore them and fix it.
I am experienced with Java and have some experience with PHP (the server scripting language I will be using unless anybody tells me I shouldn't for some reason. I want to just send a string via POST to the server. Because there is not actually a webpage being created, I can't just echo the string if it is received. How should I test if the string was received by the server?
Edit:
After further research, it seems like echo doesn't just print to a browser, it sends a string through the http connection to whatever is connected to the php page. I should then be able to echo a response and receive it through an input string on the Java end. Is this correct?
You could use echo, as you mentioned, but the more common and reusable method of debugging PHP as you progress is the use of error_log(). You can view its output on the PHP server in the php.log file, commonly found at /tmp/php.log.
You can watch this file in real-time via the Unix command tail -f /tmp/php.log.
Further, you can output various forms of data by calling it with print_r() like error_log(print_r($data, TRUE));.
I believe you should be properly sending back Responde codes in your php scripts.
Please check: How to send a status code in PHP and Android: How get the status-code of an HttpClient request.
My webserice provider provides HTTPS services and I need to consume them. I'm using JAX-WS and invoking the webservice with given HTTPS URL, The response is coming as expected, but when I see the logs it says HTTP request and the request XML is not encrypted, I enabled
"com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true;"
to print the logs in console.
Is that a behavior when we print XML in console,
If I want to see encrypted XML, What should I do
I'm not sure whether encryption is happening when transmitting the request.
If you are on Linux, you can use Socket Stat ss -pr for inspecting open sockets (and whether they are secure). On BSD (but also on Linux), use netstat, while I'm sure there is a similar tool also on Windows, although I never used one.
Otherwise, use a network inspecting tool like Wireshark or Tcpflow/Tcpdump and see whether the messages are sent over HTTPS or not.
Note: these tools will only confirm that a TLS/SSL connection is present, they cannot substitute a thorough security audit.
My system:
Server: Java Soap Web Service generated by JAX WS 2.2.3 (-wsgen)
Client: iOS - Soap Web Service generated by SudzC
I am using SudzC on iOS to communicate with a Java web service. I want to upload NSData files from the iOS client to the Java Server or download byte[] files from the Java server to the client. For small amounts of data the web service runs fine, but when the data is greater than 4MB, there are problems. If i send a file which is greater than 4MB a HTTP Internal Error 500 occurred or everything get stuck and my application crashes.
Any suggestions? Perhaps, should I try something else than SudzC?
I know, that to send and receive large files, SOAP has an opportunity called MTOM.
This extracts the base64Binary data from the SOAP message and packages it as separate binary http attachments within the MIME message, in a similar manner to e-mail attachments.
So my problem is, how can i implement this option on the iOS client SudzC generated objective-C program code?
On the java server side the MTOM option is activated, but on the iOS client i have to implement this option?!
Perhaps someone can help?
I use WSClient++ to generate the classes and never had a problem.
http://wsclient.neurospeech.com/
I don't like SudzC, I have any problems when XML return has list of list.
I've used SudzC to upload larger files (20 + megabytes) so the issue probably isn't from SudzC. I remember having an issue with the file upload at the beginning aswell : the server didn't accept anything over X bytes and was returning an error.
However, what i have seen is that sudzC has a lot of issues with memory when uploading large files so i switched to wsdl2objc for file upload