Hi I have a problem when I try to acces a webservice. Calling the Webservice I get a message that said I am no Authorized to acces.
The following Code is used to accessed the Webservice.
Can anybody suggest were look. On the server-side or in the following Javacode. Since My Experiance is not big with Java-Coding I appreciate any alternativ loging method if there a better than beneath.
public synchronized
String echoString( String inputString )
throws SOAPException {
String retval = "";
SOAPHTTPConnection conn = new SOAPHTTPConnection();
String Username= "194.33.22.33//administrator";
String Password= "Qwert6y";
conn.setUserName(Username);
conn.setPassword(Password);
if (url == null) {
throw new SOAPException(Constants.FAULT_CODE_CLIENT,
"A URL must be specified via " +
"SoapBuildersExSoapProxy.setEndPoint(URL).");
}
// Instantiate the message and the envelope.
// The message sends the envelope and gets
// the response.
Message message = new Message();
Envelope env = new Envelope();
message.setSOAPTransport(conn);
DataHandler soapMsg = null;
// Get this from the soapAction attribute on the
//
soap peration element that is found within the SOAP
// binding information in the WSDL.
String SOAPActionURI = "http://tempuri.org/echoString";
MessageBody theBody = new MessageBody();
// Set the argument.
theBody.echoString = inputString;
// Replace the default body with our own.
env.setBody( theBody );
message.send( getEndPoint(), SOAPActionURI, env );
try{
// Because the Body.unmarshall handler is static,
// you cannot replace the basic machinery easily.
// Instead, you must obtain and parse the
// message on your own.
soapMsg = message.receive();
XMLReader xr = XMLReaderFactory.createXMLReader(
"org.apache.xerces.parsers.SAXParser");
ClientHandler ch = new ClientHandler();
ch.setElementToSearchFor("echoStringResult");
// Set the ContentHandler.
xr.setContentHandler( ch );
// Parse the file.
xr.parse( new InputSource(
new StringReader( soapMsg.getContent().toString() ) ) );
// At this point, the result has been parsed and stored
// within the ClientHandler instance.
retval = ch.getResult();
} catch ( Exception e ) {
// You need to do something with the exception.
// Here, we print out the exception to the console.
System.out.println( "***Exception***: " + e.toString() );
}
return retval;
}