I need to add api service using wso2 api management or wso2 ei. i have a web api with ip:port format that have response via postman but when i add web api in api manager or wso2 ei in api menu and call published api via postman i get this error
method not allowed and in log i have this error : main sequence executed for call to non-existent = /CardTransfer/
my API Source :
<api xmlns="http://ws.apache.org/ns/synapse" name="NoorService" context="/CardTransfer" version="v1" version-type="url">
<resource methods="POST">
<inSequence>
<log level="full">
<property name="befor" value="befor"/>
</log>
<send>
<endpoint>
<http uri-template="http://x.x.x.x:9110/"/>
</endpoint>
</send>
<log level="full">
<property name="after" value="after"/>
</log>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
</api>
The request URL for the API resource you have created is:
https://<ip>:<port>/CardTransfer
the forward slash end of the API context should be omitted.
If the API resource contains a url-mapping="/", the request URL would be:
https://<ip>:<port>/CardTransfer/
Related
We are running into an issue where a call to a WSO2 API REST endpoint fails with a "412 Precondition Failed" when the Content-Length exceeds 1068. Just adding a space to the request (increasing size to 1069) causes this failure. This issue can also happen when content length is less than 1069, if the API is called fast enough (using SOAPUI for testing). We have a theory that the header and body are split between packets and confuses the request. We tried turning off chunking and that didn't affect things. When the back end REST service is called directly it works fine.
You can turn off the chunking as below by using the property mediator if you are calling the SOAP endpoint. But you have to make sure that the SOAP endpoint is also expecting a non-chunked request.
<property name=”DISABLE_CHUNKING” value=”true” scope=”axis2″/>
But if you are using REST endpoint above property may not work sometimes. In that kind of situation, we need to make sure the Content-Length header is appended to the request. We can use below two properties to append the Content-Length header.
<property name="FORCE_HTTP_CONTENT_LENGTH" value="true" scope="axis2"></property>
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"></property>
Sample proxy inSequence
<inSequence>
<log level="custom">
<property name="msg" value="Executing IN sequence"></property>
</log>
<property name="FORCE_HTTP_CONTENT_LENGTH" value="true" scope="axis2"></property>
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"></property>
<send>
<endpoint>
<address uri="https://www.google.com" format="rest"></address>
</endpoint>
</send>
</inSequence>
I have two proxy services for testing purpose that connects with JIRA using JIRA Connector. First one, accepting "application/json" payload:
<proxy name="PruebaJIRA_01" startOnLoad="true" trace="disable" transports="https http">
<description/>
<target>
<inSequence>
<log level="full"/>
<jira.init>
<username>xxxxxx</username>
<password>xxxxxx</password>
<uri>http://gea-jira.its.ute.com/jiragea</uri>
</jira.init>
<property expression="json-eval($.consulta)" name="query"/>
<jira.searchJira>
<query>{$ctx:query}</query>
</jira.searchJira>
<log level="full"/>
<respond/>
</inSequence>
</target>
</proxy>
The second one, accepting "text/xml" payload:
<proxy name="PruebaJIRA_02" startOnLoad="true" trace="disable" transports="https http">
<description/>
<target>
<inSequence>
<property name="messageType" scope="axis2" value="application/json"/>
<log level="full"/>
<jira.init>
<username>xxxxxx</username>
<password>xxxxxx</password>
<uri>http://gea-jira.its.ute.com/jiragea</uri>
</jira.init>
<property expression="//root/consulta" name="query"/>
<jira.searchJira>
<query>{$ctx:query}</query>
</jira.searchJira>
<log level="full"/>
<respond/>
</inSequence>
</target>
</proxy>
It seems that JIRA connector only accept JSON incoming data, so in the second one I have a "messageType" conversion at the top of the sequence.
Both services run OK, but the question is: Why is the second proxy working if I am using an xpath expression?
I am using wso2 ESB 4.9.0.
Thanks in advance.
ESB receives disparate message formats from different clients and systems, because of this ESB required a canonical message format inside the ESB to do all the message mediation tasks. Because of this the message builder used to convert the incoming messages into a canonical format. The canonical format using inside the ESB is SOAP. So surely your XPATH expression works with the soap message.
MessageType property used to select correct message formatter and the message formatter is used to build the outgoing stream from the proxy.
More Info - demystifying-wso2-esb-pass-through-transport /
Working with Message Builders and Formatters
I'm trying to call a web service in tomcat through api resource in WSO2 ESB.
The resource is:
<resource methods="DELETE" url-mapping="/weight/delete">
<inSequence>
<log level="custom">
<property name="Access token value" expression="$trp:Authorization"/>
</log>
<oauthService remoteServiceUrl="https://host:port/services/" username="username" password="password"></oauthService>
<header name="Authorization" scope="transport" action="remove"></header>
<send>
<endpoint>
<address uri="http://host:8080/web-services/services/proyect1"></address>
</endpoint>
</send>
</inSequence>
It hasn't query params and path params.
But I have an 500 internal server error, and tomcat throw this exception:
Caused by: com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
The request is:
Method: Delete
http://host:8282/web-services/services/proyect1/weight/delete
Head: Authorization: Bearer 89712389712hd97861h
Payload: [{"id":"307"}]
All is correct sending request directly to tomcat.
According to REST, delete method in HTTP must not content payload. Then, http://host:8282/web-services/services/proyect1/weight/delete it's not correct.
But, to resolve this problem I can use a PayLoadFactory mediator in WSO2 to send JSON to endpoint.
I have this simple example of my rest api, and now I want to add https capabilities to this resource.
<api name="API_FEETIT_VERSION" context="/api_feetit_version">
<resource methods="GET" protocol="https">
<inSequence>
<send>
<endpoint>
<address uri="http://myserver.net/version"/>
</endpoint>
</send>
</inSequence>
</resource>
To do this I just added attribute protocol="https" on resource, but now I cant access the service. Already try on port 8243 but still nothing.
Do I need to do anything else? Or even my endpoint service needs to use https too?
Yes , your backend service will need to be https as well as your endpoint address.
<address uri="https://myserver.net/version"/>
Log in to the ESB Management console.
Under "Service Bus" section/tab , click the last option "Source View".
Search(ctrl-f) for you API , then its resource , and check if protocol="https". This is one of mine:
< resource methods="POST"
protocol="https"
inSequence="ackServiceSeq"
outSequence="hcfRequest"/ >
Weird how the "invokation url" stays the same
I have Created a queue named NewJMSQueue in ActiveMQ, using ActiveMQ management console.
I am trying to produce a message in this queue using WSO2 ESB message producer. Below are the source of my producer.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="JmsProducerTest" transports="http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<property name="OUT_ONLY" value="true"/>
<send>
<endpoint>
<address uri="jms:/NewJMSQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue"/>
</endpoint>
</send>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<log level="full"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
<description></description>
</proxy>
but i am getting following ERROR in WSO2 ESB console
[2013-09-20 11:37:51,777] ERROR - BaseUtils JNDI lookup of name dynamicQueues/NewJMSQueue returned a org.apache.activemq.command.ActiveMQQueue while a
interface javax.jms.Destination was expected
[2013-09-20 11:37:51,777] ERROR - Axis2Sender Unexpected error during sending message out
org.apache.axis2.transport.base.BaseTransportException: JNDI lookup of name dynamicQueues/NewJMSQueue returned a org.apache.activemq.command.ActiveMQQ
ueue while a interface javax.jms.Destination was expected
at org.apache.axis2.transport.base.BaseUtils.handleException(BaseUtils.java:167)
at org.apache.axis2.transport.jms.JMSUtils.lookup(JMSUtils.java:522)
at org.apache.axis2.transport.jms.JMSUtils.lookupDestination(JMSUtils.java:718)
at org.apache.axis2.transport.jms.JMSOutTransportInfo.getDestination(JMSOutTransportInfo.java:184)
at org.apache.axis2.transport.jms.JMSOutTransportInfo.loadConnectionFactoryFromProperties(JMSOutTransportInfo.java:132)
at org.apache.axis2.transport.jms.JMSOutTransportInfo.createJMSSender(JMSOutTransportInfo.java:330)
at org.apache.axis2.transport.jms.JMSSender.sendMessage(JMSSender.java:124)
at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:112)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutOnlyAxisOperation.java:297)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:456)
I have added following jar files. geronimo-j2ee-management_1.1_spec-1.0.1.jar, geronimo-jms_1.1_spec-1.1.1,jar hawtbuf-1.9.jar, activemq-broker-5.8.0.jar, activemq-client-5.8.0.jar, activemq-all-5.8..
once i removed activemq-all-5.8.0.jar it is working fine.