Web services Salseforce Apex类支持Apache axis存根身份验证

Web services Salseforce Apex类支持Apache axis存根身份验证,web-services,salesforce,apex-code,axis,Web Services,Salesforce,Apex Code,Axis,我们已经将Web服务的WSDL文件转换为salesforce apex类。Web服务正在接收Apache axis存根身份验证用户名和密码格式的身份验证凭据 下面是Apache axis存根身份验证用户名和密码示例。 Service service = new XYZServiceLocator(); URL endpointURL = new URL("https://urllink"); XYZServiceSoapBindingStub stub = new XYZServiceSoap

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

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

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存根身份验证用户名和密码功能吗

由于Apex存根支持HTTP头身份验证,它是否也支持Apache axis存根身份验证

下面是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

请帮助我解决此问题。

将apex代码转换为以下代码后,我成功地解决了此问题

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头身份验证过程。如果有其他方法进行身份验证,请提及。

看起来您已经找到了解决方案

为了便于参考,请查看联机文档中有关执行基本身份验证头的部分