Amazon Product Advertising API does not Match Documentation (Java)? - java

Hey all, got a question. I'm using the tutorial for Amazon Product Advertising API (here) for Java. I've generated the client code via the WSDL they provide. When going through the code for an ItemLookup, I get to a section where I reference AWSECommerceServicePortType.itemLookup() by passing in an ItemLookup object, I get a compile error. It seems that .itemLookup() is actually looking for quite a number of params - in other words, the method signature does not match the tutorial. What am I missing? Thanks in advance!

To generate the Product Advertising API Client Side Library stubs
1. Go to the directory where you want to generate the stubs and create a "build" directory and a "src" directory. All of the generated source code will go under the "src" folder.
2. Create a custom binding to disable "Wrapper Style" code generation.
<jaxws:bindings
wsdlLocation="http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
This step is necessary because the IDE does not support wrapper style generated code.
3. Run the command:
wsimport -d ./build -s ./src -p com.ECS.client.jax http://ecs.amazonaws.com/AWSECommerceService/AWSECommerceService.wsdl -b jaxws-custom.xml .
You can find the generated stubs in the path, com.ECS.client.jax .
Extract from the docs (page 10 from the pdf file)

Related

Not able to find Face and FaceRecognition classes

I am working on Face Recognition java project using OpenCV 3.4.0. For that using createFisherFaceRecognizer(0,1500) method but OpenCV doesn't contain this class and method. Does anyone know about OpenCV? Please let me know how to use it.
These are imports
import org.opencv.face.Face;
import org.opencv.face.FaceRecognizer;
Thanks in advance.
There is another thing called OpenCV-contrib that is required to run the following Face class .
This is the GitHub repo link . Read the README.md
Follow the given steps : -
Download the original OpenCV repo and the contrib repo from GitHub.
Go to opencv_contrib/modules/face and open cmakeLists.txt with any editor . Now find the line that begins with ocv_define_module and add the word 'java' (no quotes) in the end .
[Looks like:-
ocv_define_module(face opencv_core opencv_imgproc opencv_objdetect WRAP python java)]
3.Compile using cmake using this : cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_EXTRA_MODULES_PATH=path to opencv_contrib
Use the generated jar!
PS:In windows , I don't think the default .exe opencv installer contains the face classes , so its better to build with cmake .
org.opencv.face is not available with OpenCV. For that, opencv-contrib is required which can be easily added. Follow the link:
opencv-contrib library

Cannot generate C# proxy dll with JNI4NET tool, running batch file as trusted assembly?

I am working on getting the tool JNI4NET working so that I can use some Java code I have within my C# application. As a simple initial test I have created a simple Java class library with a single class Person with one method public String GetName() { return "NoBody"; }. From here I have been following along with the samples given in the JNI download to edit the generateProxies.cmd to create the DLL wrapper of the jar.
I didn't have much luck with this so I decided to try to perform the same action but with the sample, specifically the sample entitled myJavaDemoCalc. When executed generateProxies.cmd in the sample folder an error is thrown.
(I will transcribe this picture if need be)
I have followed the link in the exception though while I somewhat understand what it means I am not sure if it is necessarily safe to enable loading from remote sources as it suggests at the end of the linked article.
I am also confused why the exception is being thrown seeing that the generateProxies.cmd and thus ProxyGen.exe is being run from my C: drive.
Anyone have an idea of what I could try next or know the issue here?
For reference here is the generateProxies.cmd source from myJavaDemoCalc
#echo off
copy ..\..\lib\*.* work
..\..\bin\proxygen.exe work\myJavaDemoCalc.jar -wd work
cd work
call build.cmd
cd ..
echo compiling usage
csc.exe /nologo /warn:0 /reference:work\jni4net.n-0.8.8.0.dll /reference:work\myJavaDemoCalc.j4n.dll /out:work\demo.exe /target:exe MyCalcUsageInDotnet.cs
I assume you downloaded that zip file and then immediately Extracted all files.
However, because that zipfile did originate from an untrusted zone, being the internet, the files in it will also remain untrusted. It contains an alternate data stream with a zone identifier.
When those assemblies get loaded by the framework, it checks if they can be trusted. Assemblies with that zone identfier still present don't get loaded. That is the exception you get:
System.IO.FileLoadException: Could not load file or assembly 'file:///jni4net.n-0.8.8.0.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) --->
System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch.
The quickest solution to resolve this is to open the properties window of the downloaded zip file and tick unblock before you extract all files:
If you already extracted all the files to a folder you can use the powershell command unblock-file
Get-ChildItem -Path 'c:\path\to\files' -Recurse | Unblock-File
But if you're sure that you will always run proxygen.exe with trusted assemblies, you can add the suggestion offered in the MSDN article by adding the loadFromRemoteSources element in the existing proxygen.exe.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
<!-- trust all the thingz -->
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>

WS02 generates POM but no source code

Having recently upgraded from WS02 3.1.0 to 5.2.1 I also upgraded the associated axis2 and rampart versions to 1.5 and 1.6.2 respectively.
The WSo2 server runs up and creates my list of services and they are all present on the WSO2 console page.
My problem is that, due to the upgrade (axis2), I now have to regenerate the stubs that support our test harness in order to test those services as some classes/interfaces have changed and methods (e.g. org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter) are no longer present.
According to the notes left by the originator of the current stubs I need to open the list of services and then copy the WDSL2.0 link. Then open the WDSL2Java page on "Tools", paste the link into the uri field, select the version as 2.0 and generate. This is broadly what the WSO2 help page suggests too.
However, when I follow this procedure, this generates a .zip file which contains only a single .POM file (which has a link to the WSDL file in it).
The "generate" page is showing a set of MAVEN information above it which doesn't appear on the help page explanation.
My project is not MAVEN based so my question is how to get the source files generated in the same manner as they were, seemingly, created with WSO2 version 3. The WSDL2.0 file opens when I enter the URL into a browser and contains the details of the associated classes/methods as expected so that seems to be OK.
Is there some configuration I can tweak to turn off the MAVEN POM generation?
Having spent over a day on this I would really appreciate any help.
Greg
Finally found a solution to this after much experimentation:
Start your services with WSO2
Login to the WSO2 console web page and list the services
From the WSDL2 column copy the link to the WSDL file
From the cmd line navigate to axis2/bin
Enter WSDL2Java -uri [paste the url of the WSDL file here] -sd adl -wv 2.0 -o [destination folder for the generated code here (optional)]

Using Endpoints in an iOS Client: What is "output of ServiceGenerator"?

I am following the instructions at https://developers.google.com/appengine/docs/java/endpoints/consume_ios to connect my iOS app to my app-engine endpoint. In subsection Adding required files to your iOS project at step 3 I got stuck because I don't know what also add the output of ServiceGenerator means. Will someone who has done this before please help?
You can obtain the output of ServiceGenerator following points 3,4 and 5 of Compiling the client library generator and generating your library
I'll try to explain how to do it and why:
before you can generate your iOS client library, you have to compile the tool that generates it, that's called ServiceGenerator.
To compile it, as said in the documentation, open the XCode project ServiceGenerator.xcodeproj and build the only target you have.
You'll use this tool from your terminal to generate your APIs, but for doing that you need an rpc-discovery document: a file containing some metadata that describes your APIs.
Here an example to generate a discovery rpc file from a terminal using the tool endpoints.sh
$ {your_path_to_appengine_sdk}/endpoints.sh get-discovery-doc -f rpc your.package.yourAPIclass
Then you can generate your API client files with ServiceGenerator:
{your_ServiceGenerator_path) your_rpc_discovery_file.rpc --outputDir {your_output_directory}
And of course... now you have to include the files in your iOS project!

org.apache.axiom.om.util.AXIOMUtil cannot be resolved

I'm trying to generate some stubs for a WSDL (using xmlbeans) and keep running into some issues. I'm using the following page:
http://axis.apache.org/axis2/java/core/docs/userguide-creatingclients-xmlbeans.html
The only part of these steps that I'm skipping is the "client.java" part because I already have another project ready I want to plug the resulting jars into. A quick run down of my steps are as follows:
My WSDL is a crmonline instance, so I run something like this:
C:\Work\aaa2>WSDL2Java -uri
https://mycrmorgname.crm.dynamics.com/XRMServices/2011/Organization.svc?wsdl
-p crmsdk -d xmlbeans -s -o c:\mystubfolder
I build the project using "ant"
In my "client" project I reference the 2 jars created in .\build\lib
My project builds fine once I add all my axis2 / apache references etc, but when I launch it through playframework I get errors when I hit the first page. The first error seems to be:
17:48:45,289 ERROR ~ Error in ControllersEnhancer.
controllers.ProfileController.editProfile has not been properly enhanced
(fieldAccess javassist.expr.FieldAccess#212ca458).
or something similar to that. Scrolling down through the error I can see that I'm getting this:
The file /app/models/MyDynamicsClient.java could not be compiled.
Error raised is : org.apache.axiom.om.util.AXIOMUtil cannot be resolved
Now, I haven't even hit any of my web services yet, or even instantiated any of my classes ... I'm at a loss as to why this is happening. Or to be more accurate, what exactly am I messing up! Am I missing a reference to something? Doing a search on AXIOMUtil tells me this should be in Axiom-api (version I have is Axiom-api-1.2.10.jar). I have this referenced and doesn't seem to help. Or maybe I'm doing something else wrong someplace?
Some details on versions:
Axis2 1.5.4
Apache-ant 1.8.3
Any help would be very much appreciated!!
Ok, after trying a lot of different things and rereading the sites/instructions I realised what I was doing wrong. Or at least I figured out a couple of things that I started to do differently that fixed the problem.
Firstly, I was using jar files from another sample project for the apache http components. I don't know if this had an impact, but I downloaded a fresh version of this anyway and referenced those JARS instead.
Also, instead of creating jars in my "stub" project and referencing those I copied all the generated stubs/classes directly into the existing client project. I have a feeling this might have been what fixed my problem. Or maybe a mix of this and the previous step I did!
So my new steps are as follows:
Ensure you have all the correct versions downloaded for required components. In my case I have the following:
Apache Axis 2 v 1.5.4
Apache HTTP components client 4.1.3
Apache-ant 1.8.3
Copy all the JARS from the Axis2 and HTTP Components libs into your client project and reference them.
Use WSDL2Java to create your stubs and classes within it's own project.
Ensure the project builds using Ant
Copy all the generated class files within the src folder into the source folder of your client.
Fix any other reference isssues and Build
Thankfully this got me going.

Categories