cancel
Showing results for 
Search instead for 
Did you mean: 

Integrate WebDynpro with XI using SOAP

Former Member
0 Kudos

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

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

Try appending the userid and password in the StringURL which you already have which could avoid authorization failure.

RGds,

Vasanth.

Answers (2)

Answers (2)

Andrzej_Filusz
Contributor
0 Kudos

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

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

>>>a "401 error" which means that object is not found.

this is an authorization error

Regards,

michal