cancel
Showing results for 
Search instead for 
Did you mean: 

problem when accessing the webservice - how to bypass the proxy

Former Member
0 Kudos

Hi ,

I am calling a webservice from a portal component and i am getting an error saying , unauthorised access.

when i try to access the webservice through a url in the

browser,it is aksing me UserId and Password.

1.Is this beacuse of the proxy or http port ? If it is , how can i bypass this proxy from the portal component, if i know username and password.

2.Is there anyway that i can make the webservice avaiable, supressing that user authentication.

can anyone help me asap.

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
Active Contributor
0 Kudos

Hello Lakshmi,

it is rearly bad behaviour to crosspost the same Question in 3 different forums:

/message/642272#642272 [original link is broken]

/message/642276#642276 [original link is broken]

Hope you are generous in giving points.

Regards

Gregor

Former Member
0 Kudos

Hi GREGOR,

Forgive me. But this is very critical problem i had stuck with . i wnated this to get solved anyway , so i tried to post this in all forums that are relevant to this .

I'll be generous in giing points as i do always.

Thanks,

Lakshmi

gregorw
Active Contributor
0 Kudos

Hello Lakshmi,

when it is a real critical problem you should give more information in your initial post. So it is a question and answer game. :-).

Regards

Gregor

Former Member
0 Kudos

Hi Gregor.

You have asked in the other theres if i am using NWDS.

Yes i am using the NWDS and i am calling the webserivce through JSPDynpage.

Please reply me back if you know the problem

Thanks,

Lakshmi.

gregorw
Active Contributor
0 Kudos

Hello Lakshmi,

If you use the Portal, you can configure the Proxy as described in the Documentation <a href="http://help.sap.com/saphelp_nw04/helpdata/en/33/8abf9e0ce011d7b84900047582c9f7/frameset.htm">System Properties for Proxy Server</a>.

Regards

Gregor

Former Member
0 Kudos

Thanks a lot Gregor,

I can do it only on Monday.I'll try it and let you know.

Thanks,

Lakshmi

Former Member
0 Kudos

Hi Lakshmi,

Write following code for setting username and password for your web service model.

Here, emp_vi is your Proxy object.

if ( (emp_vi != null ) && ( emp_vi instanceof javax.xml.rpc.Stub ) )

{

javax.xml.rpc.Stub stubForLogicalPort = (javax.xml.rpc.Stub ) emp_vi ;

stubForLogicalPort._setProperty( javax.xml.rpc.Stub.USERNAME_PROPERTY, "<user>");

stubForLogicalPort._setProperty( javax.xml.rpc.Stub.PASSWORD_PROPERTY,"<password>");

}

Regards,

Bhavik

Former Member
0 Kudos

Hi Bhavick,

Thanks for the reply.

There are no stubs generated , when i created, a portal service based on the WDSL file.

I followed the steps , in the example mentioned to access Google service.

Briefly,

1.I Created a "Portalsevrice from WSDL file" .

It generated a ATPservice.Java,where the code is automattially generated for calling the webservice.

2.Then i Created a jspDynpage portla component) and i am trying to access the webservice thorugh the methods generared fromt the ATPService.java

I am copying the code for your reference.

Atpservice.java

package com.myproject.disticorner.ATP;

import com.sapportals.portal.prt.service.IServiceContext;

import com.sapportals.portal.prt.session.IUserContext;

import com.sapportals.portal.prt.service.soap.ISOAPService;

import com.sapportals.portal.prt.service.soap.IPRTSOAPCall;

import com.sapportals.portal.prt.service.soap.exception.*;

import com.sapportals.portal.prt.service.soap.SOAPParameter;

import com.sapportals.portal.prt.service.soap.types.*;

import com.sapportals.portal.prt.service.soap.util.*;

import com.sapportals.portal.prt.service.soap.ISOAPParamConstants;

import javax.xml.messaging.URLEndpoint;

import java.util.Properties;

import java.io.File;

import java.io.FileInputStream;

import java.util.*;

import java.math.BigDecimal;

/**

  • Title: ATPService.java

  • Description: Virtual Portal Service of ATPService Service.

  • This file was generated automatically by the SAP PORTAL ECLIPSE PLUGINS,

  • not to modify manually

  • Plugin version: 6.3.20041102

  • @author SAP Portal EP6.0

  • @version 2005.08.25 AD at 15:13:32 EDT

*/

public class ATPService implements IServiceName {

private String mm_namespaceURI ="http://sdbxi.myproject.com/sdb/ws";

private IServiceContext mm_serviceContext;

private ISOAPService mm_soapService = null;

private String mm_urlEndpoint = null;

private Vector mm_cookies = new Vector();

private Object[] mm_cookiesFromResponse = null;

public IUserContext mm_userCxt = null;

public boolean mm_isClone = false;

public IServiceContext getContext() {

return mm_serviceContext;

}

public String getKey() {

return IServiceName.KEY;

}

public void afterInit() {

mm_soapService = (ISOAPService)mm_serviceContext.getService(ISOAPService.KEY);

}

/**

  • configure the service

  • @param configuration

  • @deprecated

*/

public void configure(com.sapportals.portal.prt.service.IServiceConfiguration configuration) {

}

public void destroy() {

}

public void init(IServiceContext serviceContext) {

mm_serviceContext = serviceContext;

}

/**

  • This method is called by the portal runtime

  • when the service is released.

  • @deprecated

*/

public void release() {

}

public void setURLEndPoint(URLEndpoint urlEndpoint){

mm_urlEndpoint=urlEndpoint.getURL();

}

public URLEndpoint getURLEndPoint(){

return new URLEndpoint(mm_urlEndpoint);

}

public IServiceName getSecurisedServiceConnection(IUserContext user){

ATPService service = new ATPService();

service.init(mm_serviceContext);

service.afterInit();

service.mm_isClone = true;

service.mm_userCxt = user;

return service;

}

/**

  • method returns an array of cookies which included in the soap response

  • extracted during the last soap call (last method called on this proxy)

  • @return an array of Cookie (javax.servlet.http.Cookie), null if no cookies are present

  • in the soap request.

*/

public Object[] getCookiesFromLastSOAPResponse() {

return mm_cookiesFromResponse;

}

/**

  • method which add a cookie (of javax.servlet.http.Cookie type) in the soap request

  • during the call of a method of this proxy class(the list of cookies is reseted after the

  • call of the method).

  • @param cookie- a Cookie (javax.servlet.http.Cookie), null if no accepted

  • in the soap request.

*/

public void addCookieInSOAPRequest(Object cookie) throws IllegalArgumentException {

if (cookie == null){

throw new IllegalArgumentException("The parameter passed is null.");

}

if (checkTypeObject(cookie)){

mm_cookies.add(cookie);

}else{

throw new IllegalArgumentException("The parameter ("cookie.toString()") passed is not a javax.servlet.http.Cookie object.");

}

}

private boolean checkTypeObject(Object obj) {

if (obj.getClass().getName().equals("javax.servlet.http.Cookie"))

return true;

return false;

}

public com.myproject.disticorner.ATP.DT_ATP_WSResponse MsgIF_ATP_WSCheck (

com.myproject.disticorner.ATP.DT_ATP_WSRequest MsgTyp_ATP_WSRequest) throws

com.myproject.disticorner.ATP.FltMsg_ATP_Error {

try {

HashMap httpheaders = new HashMap();

httpheaders.put("soapaction","http://sap.com/xi/WebService/soap1.1");

XMLAttributeHandler params = new XMLAttributeHandler();

params.addAttribute("MsgTyp_ATP_WSRequest", new SOAPParameter(null,com.myproject.disticorner.ATP.DT_ATP_WSRequest.class,MsgTyp_ATP_WSRequest));

String aUrl = "http://<host>:8000/XISOAPAdapter/MessageServlet?channel=:WebServiceClient:ATPWebservice&version=3.0&Sender.Service=WebServiceClient&Interface=http%3A%2F%2Fsdbxi.myproject.com%2Fsdb%2Fws%5EMsgIF_ATP_WSCheck";

if(mm_urlEndpoint!=null)

{

aUrl = mm_urlEndpoint;

}

IUserContext aUser = null;

String systemAlias = null;

if(mm_isClone)

{

aUser = mm_userCxt;

systemAlias = mm_serviceContext.getServiceProfile().getProperty(ISOAPParamConstants.SYSTEM_ALIAS);

}

<u><b>IPRTSOAPCall mm_soapcall = mm_soapService.getSOAPCallInstance(httpheaders,aUrl,IServiceName.KEY, mm_namespaceURI);</b>

</u>

mm_cookiesFromResponse =null;

if (mm_cookies.size()>0){

Enumeration enumeration = mm_cookies.elements();

while (enumeration.hasMoreElements())

{

Object element = (Object) enumeration.nextElement();

if (checkTypeObject(element))

mm_soapcall.addCookie(element);

}

}

com.myproject.disticorner.ATP.DT_ATP_WSResponse result = (com.myproject.disticorner.ATP.DT_ATP_WSResponse)mm_soapcall.invokeMethod("MsgIF_ATP_WSCheck", params,"http://sdbxi.myproject.com/sdb/ws", aUser, systemAlias);

mm_cookiesFromResponse = mm_soapcall.getCookiesContainInResponse();

mm_soapcall = null;

return result;

} catch (Exception soapex) {

if ( soapex instanceof PRTFault) {

Object excp = ((PRTFault)soapex).throwException();

if (excp instanceof com.myproject.disticorner.ATP.FltMsg_ATP_Error) throw (com.myproject.disticorner.ATP.FltMsg_ATP_Error)excp;

throw (PRTFault)soapex;

}else

throw new PRTFaultInternalError(this,soapex);

}

finally{

mm_cookies.clear();

}

}

}

-


and from Dynpage

i am accessing the webservice like this

public void doProcessBeforeOutput() throws PageException {

<u><b>ATPService atpservice = (ATPService) PortalRuntime.getRuntimeResources().getService("com.analog.DistiCorner.ATPService.Alias");

com.analog.Disticorner.DT_ATP_WSResponse result = atpservice.MsgIF_DistiCornerATP_WSCheck( new com.analog.Disticorner.DT_ATP_WSRequest());</b></u> //some processing here

this.setJspName("ATP.jsp");

}

-


so there are no stubs generated,which will be my stub instance then? am sure i am missing somthing else to create to call webservice.

The proxy cleint are generated when you do the samethng from webdynpro.

Please leet me know.

Thanks,

Lakshmi

Former Member
0 Kudos

Hi Gregor,

I tried following the steps in the documentation you have sent me .

the url for accessing webserive is

http://xxx.com:8000/XISOAPAdapter/MessageServlet?channel=:WebServiceClient:Soap_Client&version=3.0&S...;

I specified thae values as

Http host:xxx.com

hTTP port:8000

Proxy enable : true

user name:<username>

password:<password>

then i restarted the services, and after i logon to portal i pasetd the webservice url in the browser.but still no luck , it is again asking for the password.

My Basis Team is saying that there is no proxy involved. the pop up we are getting is only for XI system.

I did post my entire code above.please do reply if it gives more idea to my proble,m

Thanks,

Lakshmi

Former Member
0 Kudos

Hi Bhavick ,

Thanks a lot for the information You have given me. That made me look at other options of generating my webservice client.

Instaed of creating the webservice client in portal, i now created it in J2EE.

I created a standalone proxy , that has generted the stubs.

i referd that form my portal component like this

MsgIF_ATP_WSCheckServiceImpl ws = new MsgIF_ATP_WSCheckServiceImpl();

Remote remote = ws.getLogicalPort(MsgIF_ATP_WSCheckService.class);

MsgIF_ATP_WSCheck ATPws = (MsgIF_ATP_WSCheck) remote;

BaseGeneratedStub stub = (BaseGeneratedStub) remote;

stub._setProperty(Stub.USERNAME_PROPERTY , "<username>");

stub._setProperty(Stub.PASSWORD_PROPERTY , "<password>");

result = (com.analog.Webservice.types.DT_ATP_WSResponse) ATPws.msgIF_ATP_WSCheck(req);

It worked.

Thanks everyone for guiding me to the correct solution.

Lakshmi

gregorw
Active Contributor
0 Kudos

Hi Lakshmi,

if you don't have any proxy involved the Username/Password dialog is the basic authentication or your XI System. Have you tried to provide your XI Username and Password? There must also be a way to include this authentication data in the connection which will be made in your program.

Regards

Gregor

Answers (2)

Answers (2)

Former Member
0 Kudos

How I Create a Stub Connection?

guru_subramanianb
Active Contributor
0 Kudos

Hi Lakshmi,

Are you calling an Abap or java Web Service.

Hint :- Try to set the userid & psswd on the Logical port.Are you sure you have the right UME permission also to call the WS.Chk that also first.

Rdgs,

Guru

Former Member
0 Kudos

Hi Guru,

Thanks for the quick response.I had problem with my sdn id and could not login.

I am calling it through java web service.

can you please explain me in detail, how to set the userid and passwd on the logical port? how do you create it.

please reply asap.

Thanks,

Lakshmi

Former Member
0 Kudos

Hi Lakshmi,

Write following code before executing your model for Web service.

wdContext.current<node>Element().modelObject()._setusername(<user name>);

wdContext.current<node>Element().modelObject()._setPassword(<password>);

This will set your username and password for proxy. And specify proxy host in your logical ports of webservice model.

Regards,

Bhavik

Former Member
0 Kudos

Hi Bhavick ,

I think the code you have sent it is for the webdynpro.

But i am doing in JSPDynpage.CAn you let me know hoe to do it from this.

Thanks,

Lakshmi