I have to generate Java code from a wsdl file. Currently my project uses wsimport, but the wsdl file for which I have to generate code has RPC encoding. wsimport has no support for RPC. I tried using axis but it fails with following error:
soap:fault element not recognized for soap 1.2 binding
I found a jira already for this issue:
https://issues.apache.org/jira/browse/AXIS-2614
axis2 doesn't support RPC. Is there any other way I can generate the code from the wsdl using maven.
You could try using JAX-RPC instead of axis
http://docs.oracle.com/javaee/1.3/tutorial/doc/IntroWS5.html
You can also use Axis1 framework. It is old, but available on https://axis.apache.org/axis There you can find a tool called wsdl2Java, which you can execute like:
java -cp <all jars of the framework> \
org.apache.axis.wsdl.WSDL2Java \
-p <destination package name> \
-o <destination src path> \
http://[Servername]/MyService?wsdl
This generates all classes from the wsdl service description file. Then you can use the Stub classes to access the service.
The last snapshot version you can find on https://builds.apache.org/job/axis-trunk
Click on "Last Build" and then on "Distribution" (or Maven Plugin).
Related
I have a fat jar called producer which produces messages.I want to use it to produce messages to a MSK serverless cluster. The jar takes the following arguments-
-topic --num-records --record-size --throughput --producer.config /configLocation/
As my MSK serverless cluster uses IAM based authentication, i have provided the following settings in my producer.config-
bootstrap.servers=boot-url
security.protocol=SASL_SSL
sasl.mechanism=AWS_MSK_IAM
sasl.jaas.config=software.amazon.msk.auth.iam.IAMLoginModule required;
sasl.client.callback.handler.class=software.amazon.msk.auth.iam.IAMClientCallbackHandler
The way this jar usually works is by providing a username and password with the sasl.jaas.config property.
However, with MSK serverless we have to use the IAM role attached to our EC2 instance.
When my executing the current jar by using
java - jar producer.jar -topic --num-records --record-size --throughput --producer.config /configLocation/
I get the exception
Exception in thread "main" org.apache.kafka.common.config.ConfigException: Invalid value software.amazon.msk.auth.iam.IAMClientCallbackHandler for configuration sasl.client.callback.handler.class: Class software.amazon.msk.auth.iam.IAMClientCallbackHandler could not be found.
I don't understand how to make the producer jar find the class present in the external jar aws-msk-iam-auth-1.1.1-all.jar.
Any help would be much appreciated, Thanks.
I found out that it isn't possible to override the classpath specified in MANIFEST.MF in case of a jar by using commandline options like --cp. What worked in my case was to have the jar's pom include the missing dependency.
When you use the -jar command-line option to run your program as an
executable JAR, then the Java CLASSPATH environment variable will be
ignored, and also the -cp and -classpath switches will be ignored and,
In this case, you can set your java classpath in the
META-INF/MANIFEST.MF file by using the Class-Path attribute.
https://javarevisited.blogspot.com/2011/01/how-classpath-work-in-java.html
I want my custom Policy Information Point (PIP) to be able to connect to OpenStack Swift (an Object Storage application) thanks to this connector. The connector is able to retrieve metadata from an object, which would be sent back to the Policy Decision Point (PDP) when the right AttributeId is requested.
In our context, Swift holds information about our resources (objects here).
Below are all the steps I followed to try and use this connector in my custom PIP.
I got the connector to work locally (no integration with WSO2IS yet) following only the first 3 steps and calling the swift_test function in a debug-purposed main class.
I followed this guide to implement a custom PIP, which suggests using a database offering a JDBC driver (such as mariadb). My issue is that Swift does not offer a JDBC driver, hence the use of the openstack4j connector.
I added the needed openstack4j dependency to the maven project linked in the guide (here).
I also added the following imports to the extended class (named KMarketJDBCAttributeFinder in the guide):
package org.xacmlinfo.xacml.pip.jdbc;
import org.openstack4j.api.OSClient.OSClientV3;
import org.openstack4j.model.common.Identifier;
import org.openstack4j.model.storage.object.SwiftAccount;
import org.openstack4j.model.storage.object.SwiftContainer;
import org.openstack4j.model.storage.object.SwiftObject;
import org.openstack4j.model.storage.object.options.ObjectListOptions;
import org.openstack4j.openstack.OSFactory;
import org.wso2.carbon.identity.entitlement.pip.AbstractPIPAttributeFinder;
...
and this function to test and retrieve an object's metadata:
public void swift_test() {
OSClientV3 os = OSFactory.builderV3()
.endpoint(our_keystoneV3_url)
.credentials(our_keystone_username, password, domain_identifier)
.scopeToProject(Identifier.byName(our_tenant), Identifier.byName(our_domain))
.authenticate();
SwiftAccount account = os.objectStorage.account().get();
Map<String, String> md =
os.objectStorage.objects().getMetadata("our_container", "our_object");
System.out.println(md.toString());
}
which I call in the overriden getAttributeValues of the custom PIP class.
I then built the class using mvn package to generate the .jar which I copied in <IS_HOME>/repository/components/lib.
I downloaded all my dependencies using mvn dependency:copy-dependencies, and copied them all to the same <IS_HOME>/repository/components/lib folder.
I start the wso2is server, send a XACML request which involves calling my custom PIP, and see the following error in <IS_HOME>/repository/logs/wso2carbon.log:
ERROR {org.openstack4j.core.transport.internal.HttpExecutor} - No OpenStack4j connector found in classpath
ERROR {org.wso2.carbon.identity.entitlement.pip.CarbonAttributeFinder} - Error while retrieving attribute values from PIP attribute finder: org.openstack4j.api.exceptions.ConnectorNotFoundException: No OpenStack4j connector found in classpath
ERROR {org.wso2.balana.finder.AttributeFinder} - Error while trying to resolve values: Error while retrieving attribute values from PIP attribute finder: No OpenStack4j connector found in classpath
Our wso2is server, version 5.7.0 runs on a CentOS 7.6 VM.
My question is then: can we use this kind of connector in a custom PIP with wso2is? If so, how would I go about resolving the classpath issues between my dependencies?
P.S. : I previously added another custom PIP, connecting this time to a MariaDB database which is working well. The .jar I create when using mvn package contains both custom PIPs, and they are both recognized in the section "PDP > Extension" in the wso2is web interface.
Here is the list of dependencies obtained with the mvn command:
activation-1.1.1.jar
btf-1.2.jar
classworlds-1.1-alpha-2.jar
commons-codec-1.9.jar
commons-io-2.3.jar
commons-lang-2.6.jar
commons-logging-1.2.jar
guava-20.0.jar
httpclient-4.5.3.jar
httpcore-4.4.6.jar
jackson-annotations-2.7.0.jar
jackson-core-2.7.3.jar
jackson-core-asl-1.9.7.jar
jackson-coreutils-1.6.jar
jackson-databind-2.7.3.jar
jackson-dataformat-yaml-2.7.3.jar
jackson-jaxrs-base-2.7.3.jar
jackson-jaxrs-json-provider-2.7.3.jar
jackson-mapper-asl-1.9.7.jar
jackson-module-jaxb-annotations-2.7.3.jar
jboss-annotations-api_1.2_spec-1.0.0.Final.jar
jboss-jaxrs-api_2.0_spec-1.0.1.Beta1.jar
jboss-logging-3.3.0.Final.jar
jcip-annotations-1.0.jar
jcl-over-slf4j-1.7.2.jar
jdom2-2.0.6.jar
joss-0.10.2.jar
json-patch-1.9.jar
jsr305-2.0.0.jar
junit-3.8.1.jar
maven-artifact-2.0.jar
maven-compiler-plugin-2.0.jar
maven-plugin-api-2.0.jar
msg-simple-1.1.jar
openstack4j-3.1.0.jar
openstack4j-core-3.1.0.jar
openstack4j-resteasy-3.1.0.jar
org.wso2.carbon.identity.entitlement-4.2.0.jar
plexus-compiler-api-1.5.1.jar
plexus-compiler-javac-1.5.1.jar
plexus-compiler-manager-1.5.1.jar
plexus-container-default-1.0-alpha-8.jar
plexus-utils-1.0.4.jar
resteasy-client-3.1.4.Final.jar
resteasy-jaxrs-3.1.4.Final.jar
resteasy-jaxrs-services-3.1.4.Final.jar
slf4j-api-1.7.2.jar
snakeyaml-1.15.jar
Question: I am trying to call wsimport tool for a webservice using basic authentication.
Unfortunately my password has # char in it.
I tried the following :
I created a Authfile.txt with the following content in it.
http://username:pass#word#hostname:port/ws/mywebservice?wsdl
Note: The username and pass#word are the basic authentication credentials to access the web service.
And I ran the wsimport tool with the following options
wsimport -p com.example.ws -Xauthfile Authfile.txt -Xnocompile -keep -XadditionalHeaders -extension -B-XautoNameResolution http://hostname:port/ws/mywebservice?wsdl
wsimport tool throws the following error message.....
[ERROR] "http://username:pass#word#hostname:port/ws/mywebservice?wsdl" is not a valid authorization information format. The format is http[s]://user:password#host:port//
Answer:
Change the contents of the Authfile.txt file by replacing # with %40 as follows:
http://username:pass%40word#hostname:port/ws/mywebservice?wsdl
And then I ran the wsimport as before
wsimport -p com.example.ws -Xauthfile Authfile.txt -Xnocompile -keep -XadditionalHeaders -extension -B-XautoNameResolution http://hostname:port/ws/mywebservice?wsdl
Now, it generated the java files with out errors.
I had spent more than couple of hours trying to fix this issue.
Hope this helps.
When setting in the sample app: Travelocity.properties
#Specify if SAM LAssertion element is encrypted
SAML.EnableAssertionEncryption=true
And also tick the Identity server configuration option:
Enable Assertion Encryption [ticked]
Certificate Alias: wso2carbon
I receive the following error at the server log:
Error at Log: 2015-05-05 15:56:10,282 Error encrypting XMLObject
Without the encryption feature enabled, the SAML authentication flow with the Travelocity sample code starts working.
Hints are welcome how to fix this issue.
Regards,
Claude
It seems like you are working on the installed java runtime for the first time. I am using ubuntu 14. The same problem came to me. For me it worked in the following way.
1. Download the respective files according to your runtime from here.
http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html
http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
2. Extract the folder you downloaded. There will be two .jar files.
3. For ubuntu you can run echo $JAVA_HOME to find the java home. Copy above jar files into {JAVA_HOME}/jre/lib/security. You may need sudo access depending on you JAVA_HOME location. If so run the following from the location you extracted the zip file.
cp local_policy.jar /{JAVA_HOME}/jre/lib/security
cp US_export_policy.jar /{JAVA_HOME}/jre/lib/security
There should be only one slash (/) at /{JAVA_HOME}.
4. Restart wso2 identity server again and retry the procedure to login to travelocity.com
Hope this will fix your issue.
I am having the same problem as described in this jira about CORS headers. It has been fixed, but the release is showing as Fixed with r205117 (the commit).
Is there a way to obtain service packs, or do I have to build the product myself ?
As #Asela said you can build this fix for yourself.
Personally I found the instructions listed in the documentation rather lacking so thought I'd post an update on how I managed to patch it. Once I found a way to get this to work it was simple, but took a while to discover how to.
Download source
As per docs, but be aware it's a 4G+ download
svn checkout https://svn.wso2.org/repos/wso2/carbon/platform/tags/turing-chunk11 ~/wso2.chunk11
Patch code
cd to ~/wso2.chunk11/components/apimgt/org.wso2.carbon.apimgt.gateway/1.2.2/
edit src/main/java/org/wso2/carbon/apimgt/gateway/handlers/Utils.java
Build JAR
I used mvn clean compile install
Patch product
cd to product home, in my case ~/wso2am-1.7.0
cd to patches ./repository/components/patches/
mkdir and cd for the patch, in my case mkdir patch0009 ; cd patch0009
copy in the new jar there cp ~/wso2.chunk11/components/apimgt/org.wso2.carbon.apimgt.gateway/1.2.2/target/org.wso2.carbon.apimgt.gateway-1.2.2.jar .
start the product and the patch should apply.
Test patch
Assuming you've added the '*' to ~/wso2am-1.7.0/repository/conf/api-manager.xml:
<Access-Control-Allow-Origin>*</Access-Control-Allow-Origin>
You can just curl an API and see the correct header:
curl -i -X OPTIONS --header 'Content-Type: application/json' --header 'Origin: http://somewhere.com' http://192.168.1.64:8280/myApi
An check the correct domain setting is returned:
Access-Control-Allow-Origin: *
It has been fixed in the APIM 1.8.0 which has not been released yet. Therefore you may need to wait for 1.8.0 official release. I think, if you can obtain support from WSO2, they would give it as a patch. If not, you have following options.
You can find the source change with r205117 and apply it to the older APIM version (say APIM 1.7.0). To do that you need to build the relevant jar file with above diff. Ordinal source for jar file can be found at here and Source diff can be found at here. You can apply the source diff and build the jar file, then replace the orignal jar file which can be found in the APIM 1.7.0
You can build the 1.8.0 product by yourself. It would be little bit hard to build all the product and get a new pack of 1.8.0.