on 04-25-2007 9:43 AM
Hi all,
In adaptive web service model, the following methods for web service model are not supported any more:
wdContext.currentXXXXElement().modelObject()._setUser("username");
wdContext.currentXXXXElement().modelObject()._setPassword("password");
What's the new methods which have the same function in adaptive web service model? I know I could create some web service proxies in visual admin and set userName and passWord there, but I just want to know to how to hard code this information in the web dnypro program.
Thanks!
Regards,
Hui
Hui,
From <a href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/wdjava/faq-Models-AdaptiveWebService&">FAQ - Models - Adaptive Web Service</a>:
<i>nvalidResponseCodeException: Invalid Response Code: (401) Unauthorized...: The user / password provided for the WSDL was wrong or you have chosen the option No logical destinations in AWS model importer. <u>Note that for the case the WS provider requires authentication for the WSDL one <b>must</b> use the WS destinations option in the importer as WS destinations are the only way to configure authentication data needed at runtime.</u>
</i>
Valery Silaev
SaM Solutions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi valery,
Thanks for your reply. But My problem is not to set the user and password for the wsdl file during the import of wsdl. Actually I import the wsdl file from a ftp server. And I didn't get any error or expception when I import the wsdl.
My problem is the web service (not the wsdl) I want to call in web dynpro requires an authentication. I want to set the user and password in the code.
Thanks!
Regards,
Hui
Hui,
According to FAQ this is the only option.
Here is the totaly untested code you might try as well:
import javax.xml.rpc.Stub;
import com.sap.tc.webdynpro.model.webservice.api.IWDWSInvocationModifier;
import com.sap.engine.services.webservices.espbase.client.dynamic.DInterfaceInvoker;
...
wdContext.currentXXXXElement().modelObject().wdSetInvocationModifier(
new IWDWSInvocationModifier() {
public void doModifyInvocation(final Object port) {
if ( port instanceof Stub ) {
final Stub stub = (Stub)port;
stub._setProperty(Stub.USERNAME_PROPERTY, "username");
stub._setProperty(Stub.PASSWORD_PROPERTY, "password");
} else if (port instanceof DInterfaceInvoker) {
final DInterfaceInvoker invoker = (DInterfaceInvoker)port;
invoker.setProperty(Stub.USERNAME_PROPERTY, "username");
invoker.setProperty(Stub.PASSWORD_PROPERTY, "password");
} else
throw new RuntimeException("This 'clever' hack does not work");
}
public void doModifyAfterInvocation() {}
}
);
Actually, I write this code without IDE (so some names could be mispelled and syntax errors are possible) and never try it (so it can fail on deployment/run-time), but who knows, probably it works. If my assumption about port parameter is wrong you'll see error on screen.
Valery Silaev
SaM Solutions
Hi Valery,
your solution invoking the IWDSInvocationModifier-API should work but there is a simpler solution based on invoking the IWDWSModelClassExecutable-API directly.
/**
* Set WS-Runtime invocation property for the web service. Properties allowed here
* are the properties listed as name constants in {@link javax.xml.rpc.Stub}.
* @param key Key of the invocation property
* @param value Value of the invocation property
*/
IWDWSModelClassExecutable.setInvokerProperty(String key, Object value)
NOTE: Normally username and password are set by defining the Logical WS Destinations.
Regards, Bertram
Hui,
Read across the lines: constants of <a href="http://java.sun.com/j2ee/1.4/docs/api/javax/xml/rpc/Stub.html">javax.xml.rpc.Stub</a> class are valid property names, so:
import javax.xml.rpc.Stub;
...
wdContext.currentXXXXElement().modelObject()
.setInvokerProperty(Stub.USERNAME_PROPERTY, "username");
wdContext.currentXXXXElement().modelObject()
.setInvokerProperty(Stub.PASSWORD_PROPERTY, "password");
Valery Silaev
SaM Solutions
http:/www.sam-solutions.net
Message was edited by:
Valery Silaev -- added link to API docs
Hi,
This is regarding the solution given by Bertram Ganz and Valery Silaev
I am using SAP NetWeaver Developer Studio Version: 7.0.07 (Build id: 20060324033) and I could import the WSDL. Do i need to import any extra jar files or add any environmental variables to get the class IWDWSInvocationModifier and IWDWSModelClassExecutable?
I am trying to resolve the nvalidResponseCodeException: Invalid Response Code: (401) Unauthorized
N.B.
I could see the IWDWSInvocationModifier at
E:\SAP\IDE\IDE70\eclipse\plugins\com.sap.tc.webdynpro.model.webservice_2.0.0\lib\_webdynpro_model_webservice.jar
Thanks in advance
-Kailash
Edited by: Aftermarket Team on Jan 4, 2008 12:19 PM
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.