We have defined a default custom sequence for managing different gateways, as described here
We have installed the sequence as explained in the doc Creating Global Conection
The sequence only read 2 variables from environment, and uses to build the endpoint URL. This is the code:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="WSO2AM--Ext--In">
<property name="uri.var.host" expression="get-property('system','host')" />
<property name="uri.var.port" expression="get-property('system','port')" />
</sequence>
This is working fine with Published API, but if we degrade the API to prototype (for using directly without subscription), it doesn't work.
We have tried:
To install it as a Message Mediaton Policy at API level
Setting the parameter in the
/repository/resources/api_templates/prototype_template.xml In
sequence
The error when we test reports empty host name (as it tries to read the variable, and it's empty)
Do you know how to set environment variables in prototyped environment?
When the API is deployed in "Prototype Endpoint" uses the velocity_template.xml for creating the API implementation.
This template generate different code for PROTOTYPE and PUBLISHED APIs.
I have forced to include the APIManagerExtensionHandler (which is the handler processing the Custom Extension Sequence), adding the following in velocity template (after the handler adding loop).
patch --forward $WSO2_PATH/$1/repository/resources/api_templates/velocity_template.xml <<EOF
*** velocity_template.xml 2018-06-02 11:04:42.474476581 +0200
--- velocity_template.xml.patched 2018-06-02 11:07:28.495395384 +0200
***************
*** 361,366 ****
--- 361,369 ----
#end
</handler>
#end
+ #if(\$apiStatus == 'PROTOTYPED')
+ <handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler"/>
+ #end
</handlers>
#end
#end
EOF
Related
I'm having issue with what I feel is a simple url pattern match, but seeing unexpected behavior for an API I created.
I set up the API, and when I place the "URL Pattern", I do something simple like "/player/{playerId}"
When I go to the next screen to input the endpoint information, I reference my path variable as it appears in the documentation, like http://mycoolendpoint.com/playerInfo/{uri.var.playerId}
What I end up seeing is that the entire URL pattern is being appended to my endpoint. So, in the above, instead of seeing the expected http://mycoolendpoint.com/playerInfo/111, I see coming across the wire http://mycoolendpoint.com/playerInfo/111/player/111
Am I setting up something wrong when I do this syntax that it's appending the entire URL pattern to the Sandbox and Production endpoints instead of just the value of the path variable?
API's resource is normally appended to its endpoint URL by API Manager by default So to avoid this you can follow below instructions,
Create a custom sequence with the following content and save it as a .xml file.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="TestSequence">
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
</sequence>
Now edit your API in publisher. In design view go to "Message Mediation Policies" section and Enable Message mediation. Now add a In Flow and upload the previously saved sequence.
There are 2 ways you can do this by defining your API like below.
1) Define resource like this.
playerInfo/{playerId}
and define endpoint like this.
http://mycoolendpoint.com/
Or
2) Define resource like this.
/{playerId}
and define endpoint like this.
http://mycoolendpoint.com/playerInfo/
Or you can also do this as #ycr has mentioned. If you want to do that change for all APIs without creating a custom sequence file, you can add below line inside InSequence section of <APIM_HOME>/repository/resources/api_templates/velocity_template.xml file.
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
This template is used when APIM creates synapse files of new APIs.
I'm using WSO2 AM 2.0.
I'm using dynamic endpoint throught custom sequence.
The problem is that my endpoint destination adress is not showing now
I have verifyed that it is insert empty in my analytics DB.
Is there any way to add this information?
In your custom sequence, please set another property named "ENDPOINT_ADDRESS" with the same value as the one you assign to "To" header. It will solve your problem.
For consequent invokes, the destination address will be set correctly.
ex:
<header name="To" value="https://localhost:9448/am/sample/pizzashack/v1/api/menu"/>
<property name="ENDPOINT_ADDRESS" value="https://localhost:9448/am/sample/pizzashack/v1/api/menu"/>
After deploying a prototype, when trying to invoke the service without query parameters it works , but when i give the query parameter a value it will say resource not found
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>403</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>No matching resource found in the API for the given request</am:description>
</am:fault>
how can we support that any query parameter to be accepted after the URL
<resource methods="GET"
uri-template="accounts/{account_id}/asd"
faultSequence="fault">
Have you enabled JWT cahing? If you have enabled, there is a known issue in API Manager 1.9.0, which will be fixed in upcoming releases.
Thanks!
When you giving the URI pattern in the API Manger you have to give the "?*" character at the end if your URL contain query parameters. Even though swagger able to create the URL with that parameter,the runtime cannot identify it as a query parameter(runtime is based on Apache Synapse). By adding that character you are forcing the Synapse to append the query parameters to the URL.
so your template should be.
<resource methods="GET"
uri-template="accounts/{account_id}/asd?*"
faultSequence="fault">
Thanks
We are making a cfhttp call to connect to an https web service.
We are getting the this error:
Connection Failure: Status code unavailable
I searched Google but have found no solutions.
From the production server I am able to hit the web service URL.
I am a .Net developer and I am not sure of this technology.
Any pointers will be helpful.
Here is the line of code we are using to make the connection:
<cfhttp url="#arguments.TheIP#" method="post" throwonerror="true" timeout="45">
<cfhttpparam type="header" name="SOAPACTION" value="#arguments.TheHeader#">
<cfhttpparam type="XML" value="#arguments.TheXML#">
</cfhttp>
I have faced / solved this a few times, the snippet below hopefully will work for you. I highly recommend learning about it in stead of simply trying it.
I place this in my Application.cfc, but you could put it right in your script right before the cfhttp call as well.
<!--- fix for HTTPS connection failures --->
<cfif NOT isDefined("Application.sslfix")>
<cfset objSecurity = createObject("java", "java.security.Security") />
<cfset objSecurity.removeProvider("JsafeJCE") />
<cfset Application.sslfix = true />
</cfif>enter code here
Hum... First thing that appears odd is your IP argument as mentioned by barnyr. The response you are getting makes me think you are getting NO response at all (the request is completely ignored, not just erring). So some setting is causing them to ignore your request.
As of CF9 I use cfscript to do this kind of thing via HTTP when I can't use regular webservice java object proxy stubs.
Here is a working SOAP call via http() (because of .net to cf inability to communicate complex object hash maps via regular soap I resorted to this, among other things).
This is a cf to .net service call so it might be relevant for you as they are using just the built in tools to gen their SOAP service which was not perfectly Axis 1 SOAP happy-go-lucky.
In particular I had to play with some of the extra settings and headers to get it just so and specifically add the soap action into a header (which is usually derived from the SOAP body envelope).
Additionally, I am using oasis security which I had to stuff inside the envelope/body.
Here is the code (inside a cfc) that you might try updated as you need:
//////////////////////////////////////////////////////////////////////////
// BUILD HTTP REQUEST
//////////////////////////////////////////////////////////////////////////
Local['SoapAction'] = "XYZ.Commercial.Mapping.ServiceContracts/IService/#Arguments.szMethodName#"; // THIS IS CASE SENSITIVE
var oH = new Http();
oH.setMethod('post');
oH.setCharset('utf-8');
oH.setUserAgent('Axis/1.2.1');
oH.setTimeout(30);
oH.setURL(Arguments.szURL);
// INCLUDING THE SOAPACTION AS A HEADER IS SPECIFIC TO XYZ - USUALLY THE OPERATION IS DECIPHERED FROM THE ENVELOPE BODY TAGS - XYS REQUIRES THIS PATHING TO MATCH FOR THE SOAP ACTION HEADER VALUE
oH.addParam(type="HEADER", name="SOAPAction", value='#Local.SoapAction#');
oH.addParam(type="HEADER", name="Content-Type", value='text/xml');
oH.addParam(type="body", value=Arguments.szBody);
///////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// EXECUTE HTTP
Local['rsHttpSend']= oH.send();
// SET RESULTS
Local.nStatusCode = val(Local.rsHttpSend.getPrefix().StatusCode);
Local.szResponse = Local.rsHttpSend.getPrefix().FileContent;
Local.szHeader = Local.rsHttpSend.getPrefix().Header;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
This approach was coupled with using SoapUI to verify the final soap body post was valid. So if you can do that too, you should be able to use this vector.
Let me know if you get any farther.
Here are a list of things to check:
The variable for the URL is TheIP. Make sure this actually a properly
formatted URL, not just a URL.
Check that the target server's certificate is installed in the JVM's
trust store. in Windows and I think .Net, the system's own
certificate store is used, so if your browser can get to the URL
you're ok. In Java there is a file which contains a list of Trusted
Certs. Instructions on importing those certs are in the CF docs for
CFHTTP.
Check the ColdFusion logs for evidence of failure.
c:\coldfusion9\logs\exception.log is probably a good place to start.
Make sure your cfhttp link is correct. I face this issue and it totally based on incorrect cfhttp link.
What I want
To get this guide to work
http://blog.bigpixel.ro/2012/07/building-cc-applications-with-maven/
The Error
I'm running into into troubles with a HTTP 500 error code, which is as follows:
[ERROR] Unresolveable build extension: Plugin org.apache.maven.plugins:maven-nar-plugin:2.1-SNAPSHOT or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-nar-plugin:jar:2.1-SNAPSHOT (): Failed to read artifact descriptor for org.apache.maven.plugins:maven-nar-plugin:jar:2.1-SNAPSHOT: Could not transfer artifact org.apache.maven.plugins:maven-nar-plugin:pom:2.1-SNAPSHOT from/to Duns maven snapshot (http://duns.github.com/maven-snapshots/): Failed to transfer file: http://duns.github.com/maven-snapshots/org/apache/maven/plugins/maven-nar-plugin/2.1-SNAPSHOT/maven-nar-plugin-2.1-SNAPSHOT.pom. Return code is: 500, ReasonPhrase:( The request was rejected by the HTTP filter. Contact your Forefront TMG administrator. ). -> [Help 2]
What I've tried
I started with the 'maven getting started in 5 minutes' tutorial. This didn't go smoothly as I ran into a 500 HTTP error because of forefront that's implemented on my current network. I managed to get around this by setting the User Agent string property within my settings.xml.
<servers>
<server>
<id>central</id>
<configuration>
<httpHeaders>
<property>
<name>User-Agent</name>
<value>Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; InfoPath.1; SV1; .NET CLR 3.8.36217; WOW64; en-US)</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
This worked and I was able to get maven working for java projects.
I would have thought that that would be the end of the HTTP 500 errors but I'm still getting them whenever I try to pull plugins from a new pluginRepository.
I've followed the guide linked at top with one exception. Instead of putting the pluginRepository in the pom.xml in the parent folder, I put it into a profile within my settings.xml file. I did first try putting in the pom.xml but later pulled it out in the hopes that it would fix it.
Is there something within maven that is not honouring this User-Agent string that I've specified? Why does it work for the maven 5 minute tutorial and not for anything else?
Any help would be greatly appreciated. Thanks!
Figured it out.
Turns out I had to make another server entry for each of the plugin repositories I wanted maven to user the custom User-Agent string for by targetting the ID of the pluginRepository in the tags.
Now if only there was some way to apply the user-agent string to all future defined pluginrepositories
edit: Following up, I couldn't find a way within maven to apply the user-agent string to all pluginrepository configurations. I've come up with a work around that involves Squid as a proxy that replaces the User-Agent property in outgoing http requests with a custom defined one and configured maven to use that proxy. It works perfectly.