on 08-25-2005 3:37 PM
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
Hi Gregor,
I tried following the steps in the documentation you have sent me .
the url for accessing webserive is
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
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
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
How I Create a Stub Connection?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
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.