on 02-15-2006 12:22 PM
Hi,
I am one of the SDN members. I am trying to integrate WebDynpro with XI using SOAP. There is an object in XI, which I am trying to access through WebDynpro using SOAP.
However I am facing some problems on this. When I am trying to access the XI object through my WebDynpro application I am getting a "401 error" which means that object is not found. But when I try to access the object through the browser (using the link from the wsdl file) it first asks for a username and password and then I am able to access the object.
I have no clue why this is happening. I have tried a lot of thing but nothing seems to be working.
Is it because I am not passing the username and password in my code I am not able to access the object or is the way I am establishing the connection is incorrect ? Anyone please advice. I am enclosing a copy of my code (the action method which does all this). Let me know your thoughts on the code.
Eagerly awaiting your reply.
--Vishal Sood
The code is as follows:
public void onActionSendSOAPMessage(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionSendSOAPMessage(ServerEvent)
String SOAPXML = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<soap:Body>"
+ "<getProductDetails xmlns=\"http://warehouse.example.com/ws\">"
+ "<productID>827635122</productID>"
+ "</getProductDetails>"
+ "</soap:Body>"
+ "</soap:Envelope>";
try{
String StringURL = "This is where I placed the link";
URL url= new URL(StringURL);
// Create HTTP Connection
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(true);
connection.setRequestMethod("POST");
connection.connect();
// Done Creating HTTP Connection
// Write to XI
OutputStreamWriter out = new OutputStreamWriter (connection.getOutputStream());
out.write(SOAPXML);
out.flush();
out.close();
// Done Writing to XI
// Read Response from XI
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String XIResponse = "";
String XMLfromXI = "";//This is the string for storing the concatenated response from XI
while((XIResponse = in.readLine()) != null )
{
XMLfromXI += XIResponse;
}
//
IWDConfirmationDialog dialog4 = wdComponentAPI.getWindowManager().createConfirmationWindow
(XMLfromXI,wdControllerAPI.getControllerInfo().findInEventHandlers("OnEventNO"),"OK");
dialog4.open();
}catch (Exception e){
e.getLocalizedMessage();
IWDConfirmationDialog dialog33 = wdComponentAPI.getWindowManager().createConfirmationWindow
("Connection Error : "
+e.getLocalizedMessage(),wdControllerAPI.getControllerInfo().findInEventHandlers("OnEventNO"),"OK");
dialog33.open();
}
//@@end
}
Hi ,
Try appending the userid and password in the StringURL which you already have which could avoid authorization failure.
RGds,
Vasanth.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!!!
Sending user name and password as parameters in an url is not a good idea.
Could you try this:
(...)
// Create HTTP Connection
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
// new code
String userName = "officeboy";
String password = "secret";
String userPasswd = userName + ":" + password;
String encoding = new sun.misc.BASE64Encoder().encode(userPasswd.getBytes());
connection.setRequestProperty("Authorization", "Basic " + encoding);
// end of new code
connection.setDoInput(true);
connection.setDoOutput(true);
(...)
Of course, change values for userName and password variables.
Regards,
Andrzej
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
>>>a "401 error" which means that object is not found.
this is an authorization error
Regards,
michal
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 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.