on 07-26-2006 3:14 PM
Hi,
I am doing some SOAP message program, I have some problem while using HttpURLConnection to send message to server.
I have given my program below.
public class SampleRequest extends HttpServlet {
static String to = "http://nwserver:50000/spml/spmlservice";
SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();
SOAPConnection con = conFactory.createConnection();
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
.
.
.
.
.
.
URL urlEndPoint = new URL(to);
URLConnection urlConnection = urlEndPoint.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection) urlConnection;
httpConnection.setRequestMethod("POST");
httpConnection.setRequestProperty("userid","krishna");
httpConnection.setRequestProperty("password","krishna");
SOAPMessage reply=null;
try {
reply = con.call(message,httpConnection);
out.println("Reply: "+reply);
} catch (SOAPException e) {
System.err.println("sending request has been failed: "+e);
}
if(reply != null){
........
.........
}
else{
out.println("No reply");
}
.
.
.
.
.
.
.
.
.
output:
Reply: null
No reply
if I give as reply = con.call(message,to),
output:
Problem in server response: [Unauthorized]
Advance thanks for your help.
Regards,
Krishna.
hello krish,
had you tried putting your username/password parameters
into your SOAPHeader (i.e. from SOAPMessage.getSOAPHeader)
instead of the HTTPRequest header?
jo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you end up getting the SPML to work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Krishna,
Try :
httpConnection.setRequestProperty("Authorization", "Basic " + Base64.encodeString(username + ":" + password));
Check
http://www.javaworld.com/javaworld/javatips/jw-javatip47.html
Best regards, Maksim Rashchynski.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.