开发者

Salseforce Apex classes support Apache axis Stub authentication

开发者 https://www.devze.com 2023-04-06 22:26 出处:网络
We have converted a WSDL file of a Web serivice into the salesforce apex classes. The Web Service is receiving the authentication credentials in Apache axis Stub authentication u开发者_JS百科sername a

We have converted a WSDL file of a Web serivice into the salesforce apex classes. The Web Service is receiving the authentication credentials in Apache axis Stub authentication u开发者_JS百科sername and password format.

Below is the sample Apache axis Stub authentication username and password code.

Service service = new  XYZServiceLocator();
URL endpointURL = new URL("https://urllink");
XYZServiceSoapBindingStub stub = new XYZServiceSoapBindingStub(endpointURL, service);
stub.setUsername("username");// void org.apache.axis.client.Stub.setUsername(String username)
stub.setPassword("password");// void org.apache.axis.client.Stub.setPassword(String Password)
QueryResponse qresp = stub.webServiceCall(qr);

My question is. Can we get the Apache axis Stub authentication username and password functionality in the salesforce Apex classes.

As the Apex Stub support the HTTP Headers authentication does it also support the Apache axis Stub authentication?

Below is the Salesforce Apex stub HTTP Headers authentication code

String myData = 'username:password';
Blob hash = Crypto.generateDigest('SHA1',Blob.valueOf(myData));
encodedusernameandpassword = EncodingUtil.base64Encode(hash);
XYZBillingStub.inputHttpHeaders_x.put('Authorization','Basic ' + encodedusernameandpassword );// SALESFORCE STUB
XYZBilling.query(queryReq )// Web Service call

Please help me in resolving this issue.


After converting the apex code to the below code I was successfully able to resolve the issue.

String myData = 'username:password';
encodedusernameandpassword = EncodingUtil.base64Encode(Blob.valueOf(myData));
XYZBillingStub.inputHttpHeaders_x.put('Authorization','Basic ' + encodedusernameandpassword );// SALESFORCE STUB
XYZBilling.query(queryReq )// Web Service call

This was a simple hit and trial solution I got, And I think Salseforce apex functionality only support input HTTP Headers authentication process. If one has some other way to do the authentication please mention it.


Looks like you already figured out a solution.

For reference, have a look at the Sending HTTP Headers on a Web Service Callout section of the online docs for doing basic authentication headers.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号