Windows Authentication using Apache CFX wsdl2java - java

I am trying to use Apache CFX wsdl2java command on Mac OSX.
I have run this command ./wsdl2java .
The error I get is the following: WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition from :
Caused by : WSDLException: faultCode=PARSER_ERROR: Problem parsing ''.: java.io.IOException: Server returned HTTP response code: 401 for URL:
I believe the reason I get this error is because it requires Windows Authentication. I have tried to search on how to do this, but I have had no luck so far.
I would be extremely thankful for any help or ideas on this topic.
Thanks ahead of time.

If Axis 1.3, you can try
wsdl2java -uri http://user:pass#myapp.example.com/service/myService.wsdl
If Axis 1.4+ you can try
wsdl2java -http-proxy-user user -http-proxy-password pass -uri http://myapp.example.com/service/myService.wsdl

Use singleWsdl rather than wsdl, save it and reference the local copy in command parameters.
use abc/service/myService.singleWsdl rather than abc/service/myService.wsdl

Related

Generate Java code from WSDL file

I am new to Java. I am trying to create SOAP Web service client to consume a vendors webservice which requires username password and ssl certificate.
A vendor provided me SoapUI project file. I imported the project file in SoapUI and ran the tests. Those tests worked successfully.
I then exported the wsdl file using SoapUI and tried to generate java code using wsimport. I am unable to generate code. I am getting all sorts of errors which I tried to resolve by searching online but none of the solutions work.
I am using jdk1.8.0_152. and SoapUI version 5.3.0 by SmartBear.
I tried to use this wsimport command on command line of Windows 7:
wsimport -keep -verbose -s src vendor.wsdl
and I received this message:
[WARNING] Simple type "RiskType" was not mapped to Enum due to EnumMemberSizeCap limit. Facets count: 365, current limit: 256. You can use customization attribute "typesafeEnumMaxMembers" to extend the limit.
line 4317 of file:/C:/Projects/soapclient/vendor.xsd
With the SoapUI Project file they also sent me the below files:
jaxbbinding.xml
wsdlbinding.xml
ACORD_v2.2.0.xsd
ACORD-WSP_v2.0.0.xsd
Soap12-Envelope.xsd
xml.xsd
So tried wsimport with -b option like below:
wsimport -keep -verbose -s src vendor.wsdl -b ../jaxb/jaxbbinding.xml -b ../jaxb/wsdlbinding.xml
I received this error :
[ERROR] "file:/C:/Projects/soapclient/.../ACORD_v2.2.0.xsd" is not a part of this compilation. Is this a mistake for "file:/C:/Projects/soapclient/..../ProcessSuretyBond_1_2.xsd"?
line 13 of file:/C:/Projects/TestProjects/soapclient/..../jaxb/jaxbbinding.xml
Exception in thread "main" com.sun.tools.internal.ws.wscompile.AbortException
at com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:129)
at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2283)
at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:183)
at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:126)
at com.sun.tools.internal.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:429)
at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:190)
at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:168)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:159)
at com.sun.tools.internal.ws.WsImport.main(WsImport.java:42)
Not sure but should I request new binding files from the vendor ?
It works in SoapUI so shouldn't it work with wsimport ?
I tried all solution out there to resolve this issue including creating jaxb.properties file in jdk folder, adding jvm argument in maven's system settings etc. None worked.
I will appreciate if someone can point me in right direction and help resolve this issue. Many thanks in advance.
Try this:
wsimport ./vendor.wsdl -Xnocompile -d ./src -extension -keep -XadditionalHeaders -B-XautoNameResolution
You don’t need to use the binding files from your vendor. You will need the last 4 files you received from your vendor to make the above command work.

Passing GrobidExtractor.properties to Tika in Java?

I'm trying to write a Java application that uses the JournalParser to extract authors, citations, etc. from journal articles. The documentation for the GrobidJournalParser gives instructions for the command line app and for TikaServer. I need to point to Grobid running somewhere other than localhost:8080. I have a GrobidExtractor.properties file containing the correct URL on my classpath, but it doesn't seem to get found - I get an error because it's trying to access Grobid on localhost:8080.
WARNING: Interceptor for {http://localhost:8080/processHeaderDocument}WebClient has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: No message body writer has been found for class org.apache.cxf.jaxrs.ext.multipart.MultipartBody, ContentType: multipart/form-data
at org.apache.cxf.jaxrs.client.WebClient$BodyWriter.doWriteBody(WebClient.java:1220)
Is there some other way to tell Tika or the JournalParser where to find Grobid? The Javadocs were not helpful in this regard.
As explained in the documentation on using GROBID with Tika, if you want to configure Tika to use an alternate GROBID server you do so with a file named org/apache/tika/parser/journal/GrobidExtractor.properties
You have only called yours GrobidExtractor.properties, which is why it isn't being picked up. The full path is required
Assuming you're using Linux, using the Tika app, and with the GROBID properties in the current directory, you'd need to fix it with something like:
mkdir -p org/apache/tika/parser/journal
mv GrobidExtractor.properties org/apache/tika/parser/journal/
java -classpath .:tika-app-1.13.jar org.apache.tika.cli.TikaCLI --metadata journal.pdf

Hyperic HQ Api getting an agent

I'm a newbie with Hyperic but I'm so happy about discovering this tool it's very powerful and I think it can be adapted perfectly to my necessities. I have a problem using the API. I'm trying to use it through java directly and I'm trying to get my agent because I need it in further operations.
If I use the directly from command line it works perfectly.
./hqapi.sh agent list --host localhost --port 7080 --user hqadmin --password hqadmin --secure false
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AgentsResponse>
<Status>Success</Status>
<Agent id="10001" address="127.0.1.1" port="2144" version="4.4.0" unidirectional="false"/>
</AgentsResponse>
But when I try to get this agent in Java I get an error that I don't know how to solve.
AgentsResponse agentsResponse = agentApi.getAgents();
if(agentsResponse.getStatus() != ResponseStatus.SUCCESS){
log.info("Fail retrieving agent " + agentsResponse.getError().getReasonText());
log.info("More info " + agentsResponse.getError().getErrorCode());
Fail retrieving agent Unable to deserialize result
More info UnexpectedError
I'm using hyperic 4.4.0 so I'm using HQAPI V3.2. My java class is running inside Apache ServiceMix 4.5.3 and I added this library to my Maven repository using the .jar that is provided.
Any help will be so appreciated.
Thank you very much to everybody.
I solved it. After a while I noticed that .xsd file that builds java objects from XML file was not included inside my bundle.

PHP - Error installing JavaBridge.war

I'm trying to install JavaBridge as I want to make connections between my php files and Java files.
I need my php request a GET method to Java file, and Java file will get the ID and run some script and return with an ARRAY.
I tried to install JavaBridge, but I get errors while trying to excess to localhost:8080/JavaBridge
javax.servlet.ServletException: php.java.bridge.http.FCGIConnectException: Could not connect to server
php.java.bridge.http.FCGIConnectException: Could not connect to server
java.io.IOException: File \\.\pipe\C:\apache-tomcat-7.0.39\temp\JavaBridge939398813756155712.socket not writable
java.io.IOException: PHP not found. Please install php-cgi. PHP test command was: [php-cgi, -v]
I didn't show out all the errors here, I showed only the first line of each root cause.
I will give more details in my setup.
I'm using XAMPP all the time, with PHP, MySQL in the XAMPP.
Then I just installed Tomcat inorder to install JavaBridge.
I copied JavaBridge.war into c:/tomcats/webapps, copied JavaBridge.jar and php-servlet.jar into c:/tomcats/lib
I assume the problems should lies with the PHP, but I don't know how to fix it as well.
Install PHP again? but I'm not sure too.
Whats the problem with my setup?
Or is there others way to make connections between PHP and Java as what I stated above?
Thank you.
Have you enabled php-cgi?
Here's how u can do it. Go to: xampp\apache\conf\extra\httpd-xampp.conf and uncomment this:
<FilesMatch "\.php$">
SetHandler application/x-httpd-php-cgi
</FilesMatch>
<IfModule actions_module>
Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
</IfModule>
Restart Apache & Tomcat.

SoapUI "failed to load url" error when loading WSDL

I keep having some weird problems. The main one is that I keep getting the following error when trying to add a WSDL to a new project:
Error loading [https://.../token?wsdl]: java.lang.Exception: Failed to load url; https://.../token?wsdl, 0 -
Here's the message recorded in the error.log file:
java.lang.Exception: Failed to load url; https://.../token?wsdl, 0 -
at com.eviware.soapui.impl.wsdl.support.wsdl.UrlWsdlLoader.load(UrlWsdlLoader.java:184)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader.loadXmlObject(WsdlLoader.java:121)
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:535)
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:524)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionCache.update(AbstractDefinitionCache.java:97)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:226)
at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:149)
at java.lang.Thread.run(Unknown Source)
I verified that the application at that URL is up and running, and I can get to the WSDL from a web browser, but I keep getting this error message no matter what. I am using SoapUI 4.5.0 (32-bit) on a Windows 7 box. I've also tried the 64-bit version with the same results. It happens whether I am on VPN or not.
Do you know why I might be getting this error?
I have had the same problem. I resolved it by disabling the proxy in the SoapUI preferences.
(source : http://www.eviware.com/forum/viewtopic.php?f=13&t=12460)
In my case the server were the service was installed was configured only for TLS. SSL was not allowed. So you have to update SoapUI vmoptions file by adding the server TLS version
-Dsoapui.https.protocols=TLSv1.2
You can find vmoptions file under SoapUI installation folder:
C:\Program Files (x86)\SmartBear\SoapUI-5.0.0\bin\soapUI-5.0.0.vmoptions
I have had similar problems and worked around them by saving the WSDL locally. Don't forget to save any XSD files as well. You may need to edit the WSDL to specify an appropriate location for XSDs.
I got this error when trying to load a WebService implemented in MS Dynamics AX. Because I was connecting via VPN to my network, something went wrong with IPv6 settings. After Googling, I found the solution here: http://support.microsoft.com/kb/929852
In my case the
Error loading [https://.../token?wsdl]: java.lang.Exception: Failed to load url; https://.../token?wsdl, 0
was caused by fake certificate.
If you get the following in browser
"There is a problem with this website’s security certificate."
this is the case.
The resolution was to import a certificate to
C:\Program Files (x86)\SmartBear\SoapUI-5.0.0\jre\lib\security\cacerts
Which is default java used by SOAPUI
This could be a problem with IPV6 address SOAP UI picking. Adding the following JVM option fixed it for me:
-Djava.net.preferIPv4Stack=true
I added it here:
C:\Program Files\SmartBear\soapUI-4.5.2\bin\soapUI-4.5.2.vmoptions
Inside the wsdl file look for the import element, which looks like this :
`<import namespace="nameSpaceValue" location="Users/myname/.../targetxsdName.xsd"/>`
Change the location attribute in the above element to the location of your xsd files stored locally, and it should work.
The following solution helped me:
-Djsse.enableSNIExtension=false
In SoapUI-5.3.0.vmoptions.
This error is due to an erroneous schemaLocation in the WSDL file.
Indicate the correct location (either path on the disk or xsd url) of the xsd file in the wsdl file
exp
<xsd:import namespace="http://xyz:8080/" schemaLocation="http://172.17.16.53:9080/auth/authorizationBS?xsd=1"></xsd:import>
I had this issue when trying to use a SOCKS proxy. It appears that SoapUI does not support SOCKS proxys. I am using the Boomerang Chrome app instead.
I had this error and in my case, the problem was that I was using "localhost" in the URL.
I resolved that changing the localhost word for the respective IP, (Windows + R -> cmd -> ipconfig) then read the IP and write it to the URL replacing the "localhost" word
Close and reopen soapui. Probably is a bug of the application
Update SoapUI version to SoapUI 5.5.0. This error causes when I tried to load wsdl, because of old SoapUI version
If you are running your Web Application with the default port of 8080, please try to change the port to some other value and run your application again and trigger again your SOAPUI request. As you might have history projects in your SOAP UI workspace with port number 8080, might create issues.
My solution was to modify the java.security file:
\SoapUI-5.3.0\jre\lib\security\java.security
Comment code syntax:
#jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048
#jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024
For java version above 1.8,
Use below command to setup soapUI jar
java -jar --add-modules java.xml.bind --add-modules java.xml.ws <path for jar file+jar file name.jar>

Categories

Resources