• Post Reply Bookmark Topic Watch Topic
  • New Topic

WS Call fails from command prompt but works from IDE

 
Deepan Divakar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to invoke a WS call using SOAP over HTTP and am providing the necessary information.
--The authentication works and I get the correct soap response when I run the program from an IDE(JDeveloper).
--However, when I launch the same program from a command prompt, I get a
"<HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD><BODY><H1>401
Unauthorized</H1></BODY></HTML>"

Not sure why this is happening? The same code, works fine from IDE but not from the prompt. Any pointers will be appreciated.
Thanks.
==========================================================================
OracleSOAPHTTPConnection m_httpConnection = new OracleSOAPHTTPConnection();
Properties props = new Properties();
props.put(m_httpConnection.AUTH_TYPE, "basic");
props.put(m_httpConnection.USERNAME, "username");
props.put(m_httpConnection.PASSWORD, "welcome");
m_httpConnection.setProperties(props);
System.out.println("Username: " + m_httpConnection.getUserName());
System.out.println("Password: " + m_httpConnection.getPassword());
System.out.println("AUTH TYPE: " + m_httpConnection.getAuthType());
System.out.println("Session: " + m_httpConnection.getMaintainSession());

URL endpointURL = new URL(e_url);
Envelope requestEnv = new Envelope();
Body requestBody = new Body();
Vector requestBodyEntries = new Vector();
requestBodyEntries.addElement(payload);
requestBody.setBodyEntries(requestBodyEntries);
requestEnv.setBody(requestBody);
Message msg = new Message();
msg.setSOAPTransport(m_httpConnection);
msg.send(endpointURL, operationName, requestEnv);
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

To first thing to find out is if in both cases really the same SOAP is sent over the wire. A tool like TCPMon can visualize what's being sent, and is easy to use.
 
Deepan Divakar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,
Thanks for your reply. I have used(HTTP Analyzer)to check the message being sent across. For the IDE version, the SOAP header has the following difference:

User-AgentOracle HTTPClient Version 10h --- from command prompt
user-agentOracle-Soap-Client/1.0 HTTP/1.0 -- from IDE.

Also with the message from the command prompt,I do not see the authorization info in the header..I am really confused as to why this is happening, as it is the same code, same class file.
Any help would be appreciated.
Thanks Again Ulf.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!