wsimport Xauthfile error - java

I am trying to generate the java help classes that I need for a client (a.k.a consumer) for a SSL-protected web service (on Microsoft Biztalk) that is external to our company network. We can access it only over a proxy and we cannot change anything about the Webservice itself.
This is my command provided to the wsimport tool:
wsimport -keep -httpproxy:theProxy.net:8080 -s c:\generatedWebService_wsImport\ -p the.java.package.I.want.to.call.it -Xauthfile c:\generatedWebService_wsImport\auth https://meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
and this is the content of my auth file:
https://user:pwd#meldeservice-test.oekb.at:8080/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
And this is the error I get:
[ERROR] Server returned HTTP response code: 401 for URL: https:
//meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL,
"https:
//meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL"
needs authorization, please provide authorization file with read
access at C:\Documents and Settings\s6424.metro\auth or use
-Xauthfile to give the authorization file and on each line provide authorization information using this format :
http[s]://user:password#host:port//
Of course the proxy and credentials are different as in this post. The password contains a special character ! (exclamation mark).
Can someone help me with a working example under similar conditions. I had already searched a lot but couldn't find anything that would have helped me.
Is there somewhere a downloadable source code of the wsimport tool? This would be as the last resort to use.

Try to open https://user:pwd#meldeservice-test.oekb.at:8080/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
with your browser and save to local folder. Later you can use a wsimport like this:
wsimport -keep -s c:\generatedWebService_wsImport\ -p the.java.package.I.want.to.call.it /home/user/Download/example?WSDL
Regards,

in your request, you used
https://meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
in your auth file, it is
meldeservice-test.oekb.at:8080/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
try removing the port number, change it to
https://user:pwd#meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL

Related

How to use wsdl2java to generate code from WSDL which is secured using x.509 certificate?

I try to generate Java classes using wsdl2java.
Wsdl is located in remote server which is secured using X509 certificate, in such a way, that when I try to access it in the browser without having certificate in trust store, it is returning an error (of course when I have certificate imported into certmgr.msc, wsdl is showing just fine).
Unfortunatelly, when I try to run wsdl2java, I get:
> org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition file:/resources/wsdl/my.xml: WSDLException (at /wsdl:definitions/wsdl:types/xsd:schema): faultCode=PARSER_ERROR: Problem parsing 'https://SERVER_HOST/my?xsd=../xsd/XX.xsd'.: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
I have my certificate imported in JKS store.
How can I advise wsdl2java to use that certificate from JKS in order to connect to the serwer?
I would like suggest you skip this problem by below steps:
Download that wsdl manually to your local machine.
Dlownload that xsd files which referenced in that wsdl file manaully to your local machine.
Modify that wsdl to change xsd location to your local one.
You are fine to generate java code now.
If you really want to make it. Please refer to here:
"%JAVA_HOME%\bin\java" -Djavax.net.ssl.trustStore="{keystorefile}" -Djavax.net.ssl.trustStorePassword="{password}" -Djavax.net.ssl.keyStoreType="jks" -Dorg.jboss.security.ignoreHttpsHost="true" -Xmx128M -Djava.endorsed.dirs="%CXF_HOME%\lib\endorsed" -cp "%CXF_JAR%;%TOOLS_JAR%;%CLASSPATH%" -Djava.util.logging.config.file="%CXF_HOME%\etc\logging.properties" org.apache.cxf.tools.wadlto.WADLToJava %*
coming from : How to generate client code using wsdl2java through https?

Marklogic 6 , Calling Resource Extension in java

I need to upload and use a xquery module to marklogic 6 like check-docAvailable.xqy. I tried using the dictionary.xqy sample given by ML6, it works well. But when I try to import my own xquery I'm getting below error.
ERROR :
Exception in thread "main" com.marklogic.client.FailedRequestException: Local message: config/resources write failed: Internal Server Error. Server Message: XDMP-IMPORTMOD: Cannot import Main Module /marklogic.rest.resource/dictionary/lib/resource.xqy. See the MarkLogic server error log for further detail.
at com.marklogic.client.impl.JerseyServices.putPostValueImpl(JerseyServices.java:2033)
at com.marklogic.client.impl.JerseyServices.putValue(JerseyServices.java:1918)
at com.marklogic.client.impl.ResourceExtensionsImpl.writeServices(ResourceExtensionsImpl.java:114)
at com.mobius.ln.ml.util.MLUtil$DictionaryManager.installResourceExtensionShortcut(MLUtil.java:279)
at com.mobius.ln.ml.util.MLUtil.main(MLUtil.java:202)
My Xquery Module:
xquery version "1.0-ml";
declare namespace xs = "http://www.w3.org/2001/XMLSchema";
declare variable $uri as xs:string external;
let $uri := $uri
return (
fn:doc-available($uri)
)
Please suggest me how to achieve this. Is there any mistake in Xquery?
I would suggest a read through Extending the REST API. Your XQuery module doesn't look like a REST extension. When I attempt to install your module via curl
curl --anyauth --user admin:admin -i \
-H "Content-type: application/xquery" \
--data-binary #/c/temp/a.xqy \
-X PUT http://localhost:8000/LATEST/config/resources/a
I get the following error:
{"errorResponse":{"statusCode":400, "status":"Bad Request", "messageCode":"RESTAPI-INVALIDCONTENT", "message":"RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: invalid a extension: could not parse XQuery extension a; please see the server error log for detail XDMP-IMPORTMOD: Cannot import Main Module /marklogic.rest.resource/a/assets/resource.xqy; a either is not a valid module or does not provide extension functions (delete, get, put, post) in the http://marklogic.com/rest-api/resource/a namespace"}}
This part of the error message looks significant:
XDMP-IMPORTMOD: Cannot import Main Module /marklogic.rest.resource/dictionary/lib/resource.xqy.
That looks like you deployed dictionary.xqy as a service extension, using the REST API, then tried to import that module into another. dictionary.xqy is apparently a main module, but only library modules can be imported. See XQuery Library Modules and Main Modules in the Application Developer's Guide for more info about that.
I think what's happening is that you're deploying a main module as a service extension, but such extensions are required to be library modules. Take a look at Guidelines for Writing XQuery Resource Service Extensions in the REST Application Developer's Guide, taking note of the Resource Extension Interface section.
Solution: rewrite your extension as a library module, using the required interface.

webservices - wsimport hangs on parsing WSDL

These are my environment variables:
System variables:
JAVA_HOME C:\Program Files\Java\jdk1.8.0_20\
Path:
...;C:\Program Files\Java\jdk1.8.0_20\bin;...
I key the following in the command line:
c:\wsimport>wsimport http://www.webservicex.net/geoipservice.asmx?WSDL -Xdebug
I receive the following message
[DEBUG] Authorization file "C:\Users\myPC.metro\auth" not found. If
the WSDL access needs Basic Authentication, please provide
authorization file with read access at C:\Users\myPC.metro\auth or
use -Xauthfile to give the authorization file and on each line
provide authorization information using this format : http[s]://user:password#host:port//
parsing WSDL...
Where my configuration is incorrect?
I am not sure what happened but it's working now. It seems like my issue was perhaps related to my internet connection. I was online but the connection was pretty slow. Now everything's back to normal and my wsimport command is working.

xively java client returns status code 401

Trying to learn the Java interface to Xively. The following simple test fails with a 401 status code:
Feed myFeed = XivelyService.instance().feed().get(2126903832);
The exception statement is
com.xively.client.http.exception.HttpException: Http response status
indicates unsuccessful operation[Status code: 401.; Reason:
{"title":"Unauthorized","errors":"You do not have permission to access
this resource"} ]
The following console line leads me to believe that I'm not setting up the API key correctly:
2013-10-21 18:58:17,925 506 DEBUG [DefaultClientConnection.java:
276] (main:) >> X-ApiKey:
The Developer docs says replace <your api key> in config.properties with my API key. I did that, but it doesn't seem to make any difference.
I installed the library with Maven to my default Maven repo and point to it in Referenced Libraries. I am trying to build the whole thing in Eclipse.
My specific question is where is the config.properties the ApiConfig is reading?
I had this problem too. The problem was that I had double quotes in the config.properties file. The line should read:
api.key=yWYxyi3HpdqFCBtKHueTvOGoGROSAKxGRFAyQWk5d3JNdz0g

How to implement client code for the getting jar which is generated by wsdl2Java by CXF?

I am new to Webservice. I got xxxService.wsdl file from my client. I have generated jar using the following command with apache CXF:
wsdl2java.bat -V -d com\xxxx\service\sso -clientjar xxxwsservice.jar xxxTokenWebService.wsdl.
Now i got the jar. I am using apache-cxf-2.7.6, jdk1.6.0_37 and jboss-eap-5.1.2. My doubt is how to write the client code. Means which class is starting point to invoke the service. Is there any configuration for credentials, timeout, content type and content length.
Please advise me to implement the client.
You create the stub using wsdl2java and develop your client using the stub created.
./wsdl2java.sh -uri ~/Desktop/xxxxx.wsdl

Categories