cancel
Showing results for 
Search instead for 
Did you mean: 

Authenticating web services -- get Invalid Response Code:(401) Unauthorized

Former Member
0 Kudos

Hi,

ich have implemented a websirve in dynpro java (thanks for all the guys who wrote guides for that), but i still have a problem. i have to set username and password for authorization.

i have already tested follwoing code:

reqMo.wdSetInvocationModifier(
		 new IWDWSInvocationModifier() {
		   public void doModifyInvocation(Object port) {
			 // Creating the SOAP Header node.
			 HTTPControlInterface http = HTTPControlFactory.getInterface(port);
			 http.setHTTPProxyUserPass("xxxxx","xxxxxx");
			 
		   }
		   public void doModifyAfterInvocation() {}
		 }
	   );

but i get same message as follows:

Exception on execution of web service with WSDL 

URL 'http://server:port/special/wsdl_report_gen.wsdl' with operation '_-xxxx_-generateReport' in 

interface '{urn:sap-com:document:sap:soap:functions:mc-style}XXXX_REPORT_GEN':
Invalid Response Code: (401) Unauthorized. The requested URL 
was:"http://server:port/sap/bc/srt/rfc/sap/XXXX_report_gen/111/XXXX_report_gen/XXXX_report_gen"; 
nested exception is: 
com.sap.engine.services.webservices.jaxrpc.exceptions.InvalidResponseCodeException: Invalid 
Response Code: (401) Unauthorized. The requested URL 
was:"http://server:port/sap/bc/srt/rfc/sap/XXXX_report_gen/111/XXXX_report_gen/XXXX_report_gen"

any ideas?

Edited by: Dennis Ahaus on Dec 10, 2008 11:40 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Dennis Ahaus,

If you are using Adaptive webservice model, you can provide the credentials as below.

wdContext.currentXXXXElement().modelObject().setInvokerProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY,"username");

// wdContext.currentXXXXElement().modelObject().setInvokerProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY,"password");

Regards,

VJR.

Former Member
0 Kudos

Thanks VJR., that helps

Answers (0)