Unable to publish service with https endpoint in WSO2 API Manager - wso2

I'm trying to publish the WSO2 Message Broker services using the WSO2 API Manager.
If I enter the Message Broker URL containing https:// in the Publisher and validate the endpoint, it returns 'Invalid'. I can save the API however. Specifying http:// results in a valid endpoint.
Using SoapUI to test the EventBrokerService gives a valid response (status 202) accessing the Message Broker directly. Via the API Manager I get a soap:Fault:
<soapenv:Fault>
<faultcode xmlns:axis2ns6="http://schemas.xmlsoap.org/soap/envelope/">axis2ns6:Server</faultcode>
<faultstring>Error in Sender</faultstring>
</soapenv:Fault>
Any pointers?

This seems to be a hostname verification failure. So when you publish an API through API Manager you need to set the HostnameVerifier parameter in
<APIM_HOME>/repository/conf/axis2/axis2.xml.
<parameter name="HostnameVerifier">AllowAll</parameter>
Please refer https://docs.wso2.org/display/AM140/Creating+an+API for more information.

Related

wso2 Oauth Mediator Issue

We are using WSO2 EI 6.1.1 and WSO2 Identity server of version 5.5.0. We have a requirement of using Oauth Mediator to validate the access token. I have a service provider registered with the identity server and generated the oauth2.0 bearer access token using curl command. I tried the Oauth2webservice to validate the authorization which was succeed and request going to identity server. But if I use the Oauth Mediator of WSO2 Integrator getting the below error message and the request is not going to identity server which was confirmed from the logs of identity server.Please help on it.Is there any other jar files or configuration settings needed for the same.
<oauthService remoteServiceUrl="https://localhost:9444/services/" username="admin" password="admin"/>
ERROR - OAuthMediator Error occured while validating oauth access token.java.lang.Exception: Error while validating OAuth2 request. at org.wso2.carbon.identity.oauth.mediator.OAuth2TokenValidationServiceClient.validateAuthenticationRequest(OAuth2TokenValidationServiceClient.java:61).
Caused by: org.apache.axis2.AxisFault: SSL peer failed hostname validation for name: null.at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
I have the same issue and can't resolve, This bug has not been corrected yet
https://wso2.org/jira/browse/IDENTITY-5243

wso2 apim SOAP endpoint with username and password

I have wso2 apim 2.1 and I have request to connect to SOAP endpoint which is secured with username and password.
During add procedure of SOAP endpoint I dont have possibility to enter such credentials nor possiblity to use mediation(eg like for rest api) as I get not authorized before enetring next phase. is there a way how to do this without using ESB ?
how to connect to secured SOAP backend using just apim ?
or Do I have to use ESB and follow similar way as LINK
thank you for any advice
We were not able to parse the backend wsdl from some reason and we have done workaround by donwloading wsdl and manualy pushing it to registry, after that we were able to follow next steps.

Disable Case sensitive URLs for wso2 am

I created an api in wso2 api manager 2.0 publisher. When I publish this api, I have some resource /Some/things In the wso2 store. If I keep the case as is in the URL, then my api works. If I use any other tool to call and change the case in url to then I get a 202 error.
I know the WSO2 API Manager is handling the API URL correctly but i want to disable these feature.
how can i do this??
There is no option to disable case-sensitive in api manager. But you can rewrite the request url by any reverse proxy and send the request to apim.
e.g nginx url redirect[1]
[1] https://www.nginx.com/blog/creating-nginx-rewrite-rules/

Publish and subscribe the POST restful client in the WSO2 API-1.7

I have a post restful client which I need to publish.I am able to publish the same and post subscription, what would be the payload parameters as its a restful client.As I go through the WSO2 docs, they all refer to SOAP requests.
You do not have to send SOAP requests to WSO2 api manager. You can configure api manager to build the message to send to the backend service using you incoming request body (either json or SOAP request)
for example try this sample. This shows how a JSON request is converted to a SOAP payload to access SOAP web service backend. Here payload factory mediator is used to convert the JSON message to SOAP message. if you do not use that mediators, you would be able to send the incomming JSON body directly to backend service (if backend accepts JSON)

Retrieve username from UsernameToken scenario in web service on WSO2 Application Server

I have a WSO2 ESB WSDL based proxy service which is secured with UsernameToken scenario. This wrapper service is for an Axis2 back-end web service deployed as an .aar file in the WSO2 Application Server. What I want is to retrieve the username used for the authentication in the back-end service.
I tried to get the username using the below Java code, but it always comes back NULL:
MessageContext msgContext = MessageContext.getCurrentMessageContext();
String username = (String)msgContext.getProperty(RampartMessageData.USERNAME);
It seems that the MessageContext does not store the Rampart message data. Is there anything I can set in the WSO2 ESB to have that username be passed to the back-end service in the message context?
Thank you!
I guess, You have written a class mediator to retrieve the username from message context. Please note that, username is not in the synapse message context. It is in the axis2 message context. Please try with following code.. inside the your mediator. It has been worked for me.
Axis2MessageContext axis2Msgcontext = (Axis2MessageContext) synCtx;
org.apache.axis2.context.MessageContext msgContext = axis2Msgcontext.getAxis2MessageContext();
String userName = (String) msgContext.getProperty("username");
Or else, do you want to retrieve username in BE service (inside AS)? Then, you need to send the user name to BE services. You can use HTTP header, or any other method to send the user name to the BE service. Then you can retrieve it by using Axis2 handler. As an example you can set the user name in to HTTP header as following using synapse configuration in the WSO2ESB. Then header value would be passed to BE service
<header name="UserName" value="Test" />