简体   繁体   English

如何在WSO2 API管理器中公开带有身份验证的SOAP Web服务

[英]How to expose a SOAP web service with authentication in WSO2 API Manager

I have a SOAP web service and I can make an API call using below command. 我有一个SOAP Web服务,可以使用以下命令进行API调用。 It works fine. 工作正常。

curl --user test:test123 --header "Content-Type: text/xml;charset=UTF-8" --data @checkPayment.xml http://192.168.100.10:8081/asywspay/WSDeclarationPayment

Above mentioned SOAP service is exposed via WSO2 API Manager 1.6 and the end-point is http://api.store.com:8280/WSDeclarationPayment/1.0. 上面提到的SOAP服务是通过WSO2 API Manager 1.6公开的,端点是http://api.store.com:8280/WSDeclarationPayment/1.0. Then I make an API call using below command. 然后,我使用以下命令进行API调用。

curl --user test:test123 --header "Content-Type: text/xml;charset=UTF-8" --header "Authorization: Bearer 7bcc2235a6b0bebfbf4ff684f59f97a7" --data @checkPayment.xml http://api.store.com:8280/WSDeclarationPayment/1.0

It gives me error This request requires HTTP authentication . 它给我错误This request requires HTTP authentication Even though I pass the credentials using --user test:test123 via curl it's not passed through the API Manager. 即使我通过curl使用--user test:test123通过了凭据,也没有通过API管理器。

Given that tried it this way as well. 鉴于这种尝试也是如此。

curl --header "Content-Type: text/xml;charset=UTF-8" --header "Authorization: Bearer 7bcc2235a6b0bebfbf4ff684f59f97a7" --header "Authorization: Basic dGVzdDp0ZXN0MTIz" --data @checkPayment.xml http://api.store.com:8280/WSDeclarationPayment/1.0

Then I get error <faultcode>S:Client</faultcode><faultstring>Cannot find dispatch method for { 然后我得到错误<faultcode>S:Client</faultcode><faultstring>Cannot find dispatch method for {

How can I fix this? 我怎样才能解决这个问题?

You have a secured backend SOAP service which needs to be exposed via API Manager. 您有一个安全的后端SOAP服务,该服务需要通过API Manager公开。 When you create an API, under Endpoints section, you have to click on Show More Options , there you have to select Secured as Endpoint Security Scheme , then you can give the backend service credentials there, as shown in the below image. 创建API时,在Endpoints部分下,必须单击Show More Options ,然后在其中选择Secured as Endpoint Security Scheme ,然后可以在此处提供后端服务凭据,如下图所示。 These credentials will be used when API Manager makes calls to your backend service. 当API Manager调用您的后端服务时,将使用这些凭据。 Now we have configured the API Manager to communicate with the secured backend. 现在,我们已经配置了API管理器以与受保护的后端进行通信。

在此处输入图片说明

Then you have to create an Application in the API Store, subscribe that application to an API, generate access tokens and finally you have to use those access tokens when you invoke an API. 然后,您必须在API商店中创建一个应用程序,将该应用程序订阅API,生成访问令牌,最后在调用API时必须使用这些访问令牌。 This whole flow is well documented here [a]. 整个流程在此处[a]有详细记录。 Please go through it. 请通过它。 If you want to invoke your API without access token, you can set Auth Type to None for an API resource when you create an API. 如果要在没有访问令牌的情况下调用API,则可以在创建API时将API资源的“身份Auth Type设置为“ None ”。

[a] https://docs.wso2acom/display/AM160/Application+Developer+Guide [a] https://docs.wso2acom/display/AM160/Application+Developer+Guide

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM