Salseforce Apex 类支持 Apache 轴存根身份验证

发布于 2024-12-06 03:32:54 字数 1174 浏览 3 评论 0原文

我们已将 Web 服务的 WSDL 文件转换为 salesforce apex 类。 Web 服务正在接收 Apache axis Stub 身份验证用户名和密码格式的身份验证凭据。

下面是示例 Apache axis Stub 身份验证用户名和密码代码。

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);

我的问题是。我们可以在 salesforce Apex 类中获取 Apache axis Stub 身份验证用户名和密码功能吗?

由于 Apex Stub 支持 HTTP headers 身份验证,它是否也支持 Apache axis Stub 身份验证?

下面是 Salesforce Apex 存根 HTTP 标头身份验证代码

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

请帮助我解决此问题。

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 username 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

玩世 2024-12-13 03:32:54

将顶点代码转换为以下代码后,我成功解决了该问题。

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

这是我得到的一个简单的点击和试用解决方案,我认为 Salseforce apex 功能仅支持输入 HTTP 标头身份验证过程。如果有其他方式进行身份验证,请提及。

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.

冷情 2024-12-13 03:32:54

看来你已经找到解决办法了。

作为参考,请查看在在线文档的 Web 服务标注部分,用于执行基本身份验证标头。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文