integration between bmc remedy and serviceNow using wso2 - wso2-api-manager

we would like to integrate incident module between BMC Remedy and ServiceNow ITSM applications using ESB-WSO2, need assistance on this to achieve this integration.
Use case: Service now has to create incident then WSO2 will consume the request and process then processed request will be send to Remedy. This is nothing but a e-bonding or you can call it as ticket replication.
Any help would be much appreciated

Here is a sample API for you. Supposing that you have already installed ServiceNow connector.
You can call it from Postman using GET or browser, http://{yourWso2EiServer}:8280/serviceNow/test
After testing you can change method to POST and try to send different messages using POSTMAN. Then you will have to evaluate properties from a message, using like"expression"="json-eval($.tablename)" instead of "value"= in you Property mediators and your message must be an application/json and contain this field, like
{"tablename":"incident"....
<api xmlns="http://ws.apache.org/ns/synapse" name="ServiceNowApi" context="/serviceNow" version-type="context">
<resource methods="GET" uri-template="/test" outSequence="" faultSequence="">
<inSequence>
<property name="tablename" value="incident" description="here you can set your request variables with constants for test or read it from request using json-evalng "/>
<property name="sysparmDisplayValue" value="true"/>
<property name="sysparmFields" value="short_description,number,sys_id"/>
<property name="sysparmView" value="short_description,number,sys_id"/>
<property name="number" value="12345678"/>
<property name="shortDescription" value="Testing integration using ServiceNow connector"/>
<property name="active" value="true"/>
<property name="approval" value="owner"/>
<property name="category" value="inquery"/>
<property name="contactType" value="phone"/>
<servicenow.init>
<serviceNowInstanceURL>dev85868.service-now.com</serviceNowInstanceURL>
<username>rest_test</username>
<password>12345678</password>
</servicenow.init>
<servicenow.postRecord>
<tableName>{$ctx:tableName}</tableName>
<sysparmDisplayValue>{$ctx:sysparmDisplayValue}</sysparmDisplayValue>
<sysparmFields>{$ctx:sysparmFields}</sysparmFields>
<sysparmView>{$ctx:sysparmView}</sysparmView>
<sysparmExcludeReferenceLink>{$ctx:sysparmExcludeReferenceLink}</sysparmExcludeReferenceLink>
<sysparmInputDisplayValue>{$ctx:sysparmInputDisplayValue}</sysparmInputDisplayValue>
<number>{$ctx:number}</number>
<shortDescription>{$ctx:shortDescription}</shortDescription>
<active>{$ctx:active}</active>
<approval>{$ctx:approval}</approval>
<category>{$ctx:category}</category>
<contactType>{$ctx:contactType}</contactType>
<apiColumns>{$ctx:apiColumns}</apiColumns>
</servicenow.postRecord>
</respond>
</inSequence>
</inSequence>
</resource>
</api>

Related

logging payload of request in wso2am

with the following mediation i log headers of a request
<sequence xmlns="http://ws.apache.org/ns/synapse" name="WSO2AM--Ext--In">
<log level="custom">
<property name="system_time" expression="get-property('SYSTEM_TIME')"/>
<property name="application" scope="transport" expression="get-property('api.ut.application.name')"/>
<property name="api name" scope="transport" expression="get-property('api.ut.api')"/>
<property name="method" scope="transport" expression="get-property('api.ut.HTTP_METHOD')"/>
<property name="resource" scope="transport" expression="get-property('api.ut.resource')"/>
</log>
</sequence>
but i also want to log payload of request. how can i do it?
You can use log level as full and it will log the payload.
. However, this will parse the message content and will have a performance hit.
For more info, please visit documentation

Not able to call Dynamic Endpoints/URLs on the basis of Message Mediation polices in WSO2 API Manager

I'm using APIM-3.1.0 and I need to Redirect APIs’ based upon header or request parameter. I have tried for request parameter but unable to call different API's. I have used below custom mediation policy and added it to a test API, but unable to call the different URLs. Every time I was calling API, I was getting output for the else part (URL mention in the else part) in below code even if I am passing the value of operation as menu.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="dynamic-endpoint-seq">
<property expression="json-eval($.operation)" name="operation" />
<filter regex="menu" source="$ctx:operation">
<then>
<property name="C" expression="fn:concat('http://localhost:8080/Test/','getC')"/>
<header name="To" expression="get-property('C')"/>
</then>
<else>
<property name="B" expression="fn:concat('http://localhost:8080/Test/','getB')"/>
<header name="To" expression="get-property('B')"/>
</else>
</filter>
</sequence>
I was getting warning in Console even passing value of parameter as shown below:
[2020-07-24 17:20:38,643] WARN - SynapseJsonPath Json Payload is empty.
Is there a way to do the same or there is any error in mediation policy?
Here, you can pass value in header with some variable name and define the same in mediation policies.
The below Code calls different endpoints on the basis of variable "check" is present or not,
if it is present in header with any value,the endpoint_B will get called, if value of check is not present or check is not present in header, then it will call endpoint_C.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="dynamic-endpoint-seq-boolean">
<!--it checks the value for variabe check in header if there exist value for check
then it will call B, if value not exist or check is not present then C called-->
<property name="uri.var.check" expression="get-property('transport','check')"/>
<filter source="boolean(get-property('uri.var.check'))" regex="false">
<then>
<property name="C" expression="fn:concat('http://localhost:8080/Test/','getC')"/>
<header name="To" expression="get-property('C')"/>
</then>
<else>
<property name="B" expression="fn:concat('http://localhost:8080/Test/','getB')"/>
<header name="To" expression="get-property('B')"/>
</else>
</filter>
</sequence>
There is one more way to do the same thing, you can use Switch case in XML,as shown below and configure multiple endpoints. Here, if you pass the value of check as 'B' in header, endpoint_B will called, else if you pass value of 'check' as 'C' in header, then endpoint_C will get called, and if you pass any other value than 'B' or 'C' or not pass any value or even not pass check in header than default endpoint here endpoint_A will get called.
<sequence name="dynamic_ep_switch" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property name="uri.var.check" expression="get-property('transport','check')"/>
<switch source="get-property('uri.var.check')">
<case regex="B">
<!-- We are then assigning the endpoint which we need to route to in a property named service_ep in this step -->
<property name="B" expression="fn:concat('http://localhost:8080/Test/','getB')"/>
<header name="To" expression="get-property('B')"/>
</case>
<case regex="C">
<property name="C" expression="fn:concat('http://localhost:8080/Test/','getC')"/>
<header name="To" expression="get-property('C')"/>
</case>
<default>
<property name="A" expression="fn:concat('http://localhost:8080/Test/','getA')"/>
<header name="To" expression="get-property('A')"/>
</default>
</switch>
There is one more way to use switch if your endpoint are running on same host and port by using property="rest_url_postfix" as shown in below code. Here,output will be same as above but some changes that you need to make are for the above code you need to select dynamic endpoint in Endpoints tab in WSO2-APIM publisher while for the below code, you select REST Endpoints and select value of endpoint as http://<host_name>:<port_number>// . For example,
http://localhost:8080/Test/
<sequence name="dynamic_same_ep_switch" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<!-- The property which is retrieved as get-property('To')" stores the request URI for the API. Based on this value we will determine the endpoint which the request needs to be routed to.-->
<property name="uri.var.check" expression="get-property('transport','check')"/>
<switch source="get-property('uri.var.check')">
<case regex="B">
<!-- We are then assigning the endpoint which we need to route to in a property named service_ep in this step -->
<property name="REST_URL_POSTFIX" value="getB" scope="axis2"/>
</case>
<case regex="C">
<property name="REST_URL_POSTFIX" value="getC" scope="axis2"/>
</case>
<default>
<property name="REST_URL_POSTFIX" value="getA" scope="axis2"/>
</default>
</switch>
</sequence>
For anymore information regarding sample mediation sequences refer following links:
https://docs.wso2.com/display/APICloud/Sample+Mediation+Sequences
https://docs.wso2.com/display/ESB480/HTTP+Transport+Properties
Hope. This resolves your Query.

Bpel 12c - Call webservices with basic authentication

I'm using Oracle BPEL 12c to develop a process.
I need to call a external service with basic authentication. I need to pass the credentials received on my exposed service endpoint to the external service.
When i call, i receive this:
<remoteFault xmlns="http://schemas.oracle.com/bpel/extension">
-<part name="summary">
<summary>
oracle.fabric.common.FabricException: oracle.fabric.common.FabricException: Error in getting XML input stream:XXXXXX?WSDL: Server Authentication Required: Error in getting XML input stream: XXXX?WSDL: Server Authentication Required
</summary>
</part>
-<part name="detail">
<detail>Server Authentication Required</detail>
</part>
</remoteFault>
I tried to define on the composite, also the oracle.webservices.auth.password and oracle.webservices.auth.username password for the external service.
Also the javax.xml.ws.security.auth.username and javax.xml.ws.security.auth.password properties without sucess.
Any sugestion?
Kind regards,
Ricardo
I suppose your composite snippet should look like this:
<reference name="Service1" ui:wsdlLocation="test1.wsdl">
<interface.wsdl interface="http://tempuri.org/#wsdl.interface(IService1)"/>
<binding.ws port="http://tempuri.org/#wsdl.endpoint(Service1/BasicHttpBinding_IService1)" location="test1.wsdl" soapVersion="1.1">
<property name="weblogic.wsee.wsat.transaction.flowOption" type="xs:string" many="false">WSDLDriven</property>
<property name="oracle.webservices.auth.username" type="xs:string" many="false">test</property>
<property name="oracle.webservices.auth.password" type="xs:string" many="false">password</property>
<property name="oracle.webservices.preemptiveBasicAuth" type="xs:string" many="false">true</property>
</binding.ws>
</reference>
And also good practice to use variables when defining user and password instead of explicitly username and password
<property name="oracle.webservices.auth.username" type="xs:string" many="false">{$username}</property>
<property name="oracle.webservices.auth.password" type="xs:string" many="false">{$password}</property>
and then override them in generated cfg_plan.xml while deploying composite application
<reference name="Service1">
<!--Add search and replace rules for the binding properties-->
<binding type="ws">
<attribute name="port">
<replace>{your_port}</replace>
</attribute>
<attribute name="location">
<replace>{your_location}</replace>
</attribute>
<property name="weblogic.wsee.wsat.transaction.flowOption">
<replace>WSDLDriven</replace>
</property>
<property name="oracle.webservices.auth.username">
<replace>test</replace>
</property>
<property name="oracle.webservices.auth.password">
<replace>password</replace>
</property>
<property name="oracle.webservices.preemptiveBasicAuth">
<replace>true</replace>
</property>
</binding>
</reference>

wso2 am 2.0 ApiKeyValidator Authentication Errors

We've recently upgraded our fully functional WSO2 AM 1.10 to 2.0. The installation process gave no errors and seems to be complete. We can use the Publisher just fine. However, when we go to the Store, and go to a tab that lists all of the user's Applications, it fails, and the page is empty. The log shows:
WARN - CarbonAuthenticationUtil Failed Administrator login attempt 'MyUser[-1234]' at [2017-01-10 09:47:09,380-0500]
WARN - AuthenticationHandler Illegal access attempt at [2017-01-10 09:47:09,0380] from IP address IP-ADDRESS while trying to authenticate access to service APIKeyMgtSubscriberService
ERROR - AMDefaultKeyManagerImpl Can not retrieve OAuth application for the given consumer key : BigLongStringOfStuff org.apache.axis2.AxisFault: Access Denied. Authentication failed - Invalid credentials provided.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:445)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.wso2.carbon.apimgt.keymgt.stub.subscriber.APIKeyMgtSubscriberServiceStub.retrieveOAuthApplication(APIKeyMgtSubscriberServiceStub.java:1683)
at org.wso2.carbon.apimgt.keymgt.client.SubscriberKeyMgtClient.getOAuthApplication(SubscriberKeyMgtClient.java:89)
at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.retrieveApplication(AMDefaultKeyManagerImpl.java:234)
at org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.getClientOfApplication(ApiMgtDAO.java:2389)
at org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.getOAuthApplications(ApiMgtDAO.java:2353)
at org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.getApplications(ApiMgtDAO.java:4649)
at org.wso2.carbon.apimgt.impl.APIConsumerImpl.getApplications(APIConsumerImpl.java:3136)
at org.wso2.carbon.apimgt.impl.UserAwareAPIConsumer.getApplications(UserAwareAPIConsumer.java:36)
at org.wso2.carbon.apimgt.hostobjects.APIStoreHostObject.jsFunction_getApplications(APIStoreHostObject.java:3225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
We are using a Read Only LDAP store, the configuration is here:
<UserManager>
<Realm>
<Configuration>
<AddAdmin>False</AddAdmin>
<AdminRole>AdminGroup</AdminRole>
<AdminUser>
<UserName>MyUser</UserName>
<Password>MyPW</Password>
</AdminUser>
<EveryOneRoleName>everyone</EveryOneRoleName> <!-- By default users in this role sees the registry root -->
<Property name="dataSource">jdbc/WSO2CarbonDB</Property>
</Configuration>
<UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadOnlyLDAPUserStoreManager">
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager</Property>
<Property name="ReadOnly">true</Property>
<Property name="Disabled">false</Property>
<Property name="MaxUserNameListLength">100</Property>
<Property name="ConnectionURL">ldap://MyServer:389</Property>
<Property name="ConnectionName">CN=MyUser,OU=1,OU=2,DC=a,DC=b,DC=c</Property>
<Property name="ConnectionPassword">MyPW</Property>
<Property name="UserSearchBase">DC=a,DC=b,DC=c</Property>
<Property name="UserNameListFilter">(objectClass=user)(|(memberOf=CN=MyGroup-Subscriber,OU=1,OU=2,DC=a,DC=b,DC=c)(sAMAccountName=MyUser))</Property>
<Property name="UserNameSearchFilter">(|(&(objectClass=person)(sAMAccountName=?)(memberOf=CN=MyGroup-Subscriber,OU=1,OU=2,DC=a,DC=b,DC=c))(sAMAccountName=MyUser))</Property>
<Property name="UserNameAttribute">sAMAccountName</Property>
<Property name="DisplayNameAttribute">displayName</Property>
<Property name="ReadGroups">true</Property>
<Property name="GroupSearchBase">OU=Groups,OU=1,OU=2,DC=a,DC=b,DC=c</Property>
<Property name="GroupNameListFilter">(&(objectClass=group)(cn=MyGroup*))</Property>
<Property name="GroupNameSearchFilter">(&(objectClass=group)(cn=MyGroup?))</Property>
<Property name="GroupNameAttribute">cn</Property>
<Property name="MembershipAttribute">member</Property>
<Property name="MemberOfAttribute">memberOf</Property>
<Property name="MultipleAttributeSeparator">,</Property>
<Property name="PasswordHashMethod">PLAIN_TEXT</Property>
<Property name="UserRolesCacheEnabled">true</Property>
<Property name="ReplaceEscapeCharactersAtUserLogin">true</Property>
<Property name="MaxRoleNameListLength">100</Property>
<Property name="MaxUserNameListLength">100</Property>
<Property name="SCIMEnabled">false</Property>
</UserStoreManager>
<AuthorizationManager
class="org.wso2.carbon.user.core.authorization.JDBCAuthorizationManager">
<Property name="AdminRoleManagementPermissions">/permission</Property>
<Property name="AuthorizationCacheEnabled">true</Property>
</AuthorizationManager>
</Realm>
</UserManager>
In the Api-Manager.xml configuration for the ApiKeyValidator Key We have:
<APIKeyValidator>
<!-- Server URL of the API key manager -->
<ServerURL>https://MyURL:${mgt.transport.https.port}${carbon.context}services/</ServerURL>
<!-- Admin username for API key manager.
<Username>MyUser</Username>
<!-- Admin password for API key manager. -->
<Password>MyPW</Password>
<KeyValidatorClientType>ThriftClient</KeyValidatorClientType>
<ThriftClientConnectionTimeOut>10000</ThriftClientConnectionTimeOut>
<EnableThriftServer>true</EnableThriftServer>
<ThriftServerHost>localhost</ThriftServerHost>
<KeyValidationHandlerClassName>org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler</KeyValidationHandlerClassName>
This error did not occur in 1.10 with the same config file entries. Is there any idea as to why this happens?
So I figured out why this occurred - This will happen if the incorrect provider is listed in the user-mgt.xml file. If you see my file above, I am trying to use ReadOnly LDAP, but I have the RDBMS provider listed instead.
Changed this line and boom, everythign is functional again.

Flex + Spring + BlazeDS + Glassfish + OpenMQ - How do you configure the web-application-config for OpenMQ?

I have the spring-flex-testdrive example (JMS chat application which uses a Topic to pub/sub messages) to work on Tomcat with ActiveMQ now I want to run this example on Glassfish with OpenMQ.
This is a related sample config I found online but it doesn't quite work for the Flex/Glassfish/OpenMQ/BlazeDs/Spring-Integration technology combination.
(Link)
I can deploy it on Glassfish but it can't connect to the destination. I've seen forums mention just replace ActiveMQ with OpenMQ classes/bean declarations but that does not appear to be the case. How do you configure the web-application-context.xml for OpenMQ? What are the common gotcha's?
Thanks.
<bean id="connectionFactory" class="CustomOpenMqConnectionFactoryBean">
<property name="imqAddressList" value="localhost:7676" />
<property name="imqDefaultUsername" value="admin" />
<property name="imqDefaultPassword" value="admin" />
</bean>
<bean id="chatTopic" class="com.sun.messaging.Topic">
<constructor-arg type="java.lang.String" value="cTopic"/>
</bean>

Resources