GroovyWS WSClient Preemptive Basic authentication - grails

I cannot set preemptive authentication in groovyws. (ws provider required preemptive authentication.)
I try to find out in groovyws document but no clue.
import groovyx.net.ws.WSClient
//def proxy = new WSClient("http://202.44.4.97/webservice/pttinfo.asmx?wsdl", this.class.classLoader)
def proxy = new WSClient("http://192.168.3.69/provider/myService", this.class.classLoader)
proxy.setBasicAuthentication('user', 'pass')
proxy.initialize()
below is an error.
Caused by: java.io.IOException: Server returned HTTP response code: 405 for URL: http://192.168.3.69/provider/myService

Have you tried groovy-wslite? It says in the documentation for GroovyWS that:
Due to low availability the project is currently dormant, you might consider groovy-wslite as a replacement module
So afaics, this should get close (I'm assuming you're using SOAP):
import wslite.soap.*
def client = new SOAPClient('http://192.168.3.69/provider/myService')
client.authorization = new HTTPBasicAuthorization( 'user', 'pass' )
There are instructions for getting wslite working with Grails here.

Related

Graphstory and Neo4jphp

I have succesfully used neo4jphp library with graphenedb with this simple steps as per documentation (considering that graphenedb does not require https)
require('vendor/autoload.php'); // or your custom autoloader
// Connecting to a different port or host
$client = new Everyman\Neo4j\Client(url, port);
// Connecting using HTTP and Basic Auth
$client->getTransport()
->setAuth('username', 'password');
// Test connection to server
print_r($client->getServerInfo());
However, when trying to connect to a graphstory instance (of course they both work fine if I call the rest api from browser, the neo4j console works fine etc.) which requires https as follows
require('vendor/autoload.php'); // or your custom autoloader
// Connecting to a different port or host
$client = new Everyman\Neo4j\Client(url, port);
// Connecting using HTTPS and Basic Auth
$client->getTransport()
->useHttps()
->setAuth('username', 'password');
// Test connection to server
print_r($client->getServerInfo());
I get the following error. They should be identical, I can't get why.
Fatal error: Uncaught exception 'Everyman\Neo4j\Exception' with message 'Can't open connection to https://neo-54f500bf2cc7e-364459c455.do-stories.graphstory.com:7473/db/data/' in /Applications/XAMPP/xamppfiles/htdocs/graphene/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Transport/Curl.php:91
Stack trace:
#0 /Applications/XAMPP/xamppfiles/htdocs/graphene/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Transport.php(95): Everyman\Neo4j\Transport\Curl->makeRequest('GET', '/', NULL)
#1 /Applications/XAMPP/xamppfiles/htdocs/graphene/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Command.php(64): Everyman\Neo4j\Transport->get('/', NULL)
#2 /Applications/XAMPP/xamppfiles/htdocs/graphene/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Client.php(828): Everyman\Neo4j\Command->execute()
#3 /Applications/XAMPP/xamppfiles/htdocs/graphene/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Client.php(464): Everyman\Neo4j\Client->runCommand(Object(Everyman\Neo4j\Command\GetServerInfo))
#4 /Applications/XAMPP/xamppfiles/htdocs/graphene/story.php(20): Every in /Applications/XAMPP/xamppfiles/htdocs/graphene/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Transport/Curl.php on line 91
It seems to me that neo4jphp is not configuring the TLS part in the cURL request.
I fixed it by downloading the certificate bundle from http://curl.haxx.se/docs/caextract.html (ca_bundle.crt) and adding the following line to Everyman\Neo4j\Transport\Curl.php, function makeRequest:
$options[CURLOPT_CAINFO] = "your/path/to/ca-bundle.crt";
I've created an issue on GitHub for this: https://github.com/jadell/neo4jphp/issues/171
I'm the CTO/Lead Dev at Graph Story. Sorry to hear you're having troubles. I've actually just taken a look at your instance and things seem OK from the server side.
Without additional info it's hard to say if there's an issue with your sample connection code. Considering that you've used that same library to connect to GrapheneDB in the past, I think the chances an error in the sample code is low.
Based on the current state of your instance and on the exception thrown by Neo4jPHP, my guess is that port 7473 may be blocked on your network. You can confirm that with local tech support or by switching to a network where you know port 7473 is open and trying to connect again.

Grails:Groovy:SSLPeerUnverifiedException: peer not authenticated

I want to hit an xml request to a url while running the code in my local system it is working well i have created a war file and deployed the same in server,but while running in server getting an exception 'javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated'
i have used groovy http builder
def http = new HTTPBuilder(url)
http.auth.basic('username', 'password')
try {
http.request(Method.POST, ContentType.TEXT) {
req->
headers.accept = "application/xml"
body = request //xml request
response.success = {
resp,reader ->
Response = reader.text
}
}
}
catch(HttpResponseException ex) {
println ex;
}
how can i solve this problem in this case..?
Workaround: The following answer provides a workaround for this issue: https://stackoverflow.com/a/25076888/782034
Just found out that new version (0.7.1) of HttpBuilder introduces
method:
ignoreSSLIssues()
This solves all problems regarding invalid SSL certificates (of course
you have to be aware that it also decrease security).
More information about this method:
http://groovy.codehaus.org/modules/http-builder/doc/ssl.html (section
at the bottom)
i.e.
def http = new HTTPBuilder(url)
http.ignoreSSLIssues()
Solution: If you want to do things the 'proper' way, checkout the other solutions regarding importing the server's certificates. e.g. SSLPeerUnverifiedException: peer not authenticated
If you use ignoreSSLIssues() but still get same exception.
Just add latest httpclient into Gradle/Maven
compile 'org.apache.httpcomponents:httpclient:4.5.3'
Can't use ignoreSSLIssues in HttpBuilder version 0.7.1

Savon 2 client returning blank array for response in Ruby on Rails

I am using savon gem for integrating paysbuy in my project which is made in Ruby on Rails. This is how I am creating the savon client
client = Savon.client do
endpoint "https://www.paysbuy.com/receiveresponse/Result.aspx"
namespace "https://www.paysbuy.com/receiveresponse/ResultReg.aspx"
wsdl "https://demo.paysbuy.com/api_paynow/api_paynow.asmx"
end
logger.info"%%%%%%%%%%%%%%%%%#{client.operations}%%%%%%%%%%%%%%5555555"
But the response for "client.operations" is coming as "[]". I need help for rectifying anything wrong doing in my side. Thanks in advance for any help.
I assume you use Savon 2.x?
The syntax of your call is not correct. You need a parameter list not a block.
You also mix WSDL with WSDL less calling convention. You either specify
wsdl:
or
endpoint: ...
namespace: ...
client.operations doesn't work because you didn't give it a correct wsdl url.
Giving that's a MS based interface it is safe to assume that you can retrieve the WSDL with the parameter ?WSDL at the URL. Try this:
client = Savon.client(
wsdl: "https://demo.paysbuy.com/api_paynow/api_paynow.asmx?wsdl",
log: true,
log_level: debug,
pretty_print_xml: true
)
print client.operations
Unfortunately that call fails using Savon. I suspect it can't interpret the WSDL document.
What you can do is to use SoapUI to inspect your service and build a client without a WSDL.
client = Savon.client(
endpoint: "https://demo.paysbuy.com/api_paynow/api_paynow.asmx",
namespace: "http://tempuri.org",
log: true,
log_level: debug,
pretty_print_xml: true
)
I read the WSDL and found something which might be the namespace, but that can be tricky. Sometimes it needs some tinkering to find the correct request.
When you've found a working request using SoapUI, you need to translate it into Ruby code to make it work. That was always my approach at least.
Feel free to ask when you've reached that point.

The Http of FSharp.Data and proxy server

I'm creating a program to download web pages using the Http module of FSharp.Data. However, the module doesn't support setting http proxy server. In C# there is
_httpWebRequest.Proxy =
new System.Net.WebProxy("http://proxy.myCompany.com:80", true);
I tried to download the file from https://github.com/fsharp/FSharp.Data/blob/master/src/Library/Http.fs and use it directly in my F# project. However, the type of response changed from string to HttpResponse after I call the Http.Request from the downloaded file.
let response =
Http.Request (
url,
query=["userid", user; "password", password; "login", "Sign+On"],
meth="POST",
cookieContainer = cc)
What's the best way to extend the Http module with proxy support?
In FSharp.Data 2.0, you can pass the parameter customizeHttpRequest of type HttpWebRequest->HttpWebRequest to set the proxy like this:
Http.Request (
url,
query=["userid", user; "password", password; "login", "Sign+On"],
meth="POST",
cookieContainer = cc,
customizeHttpRequest = (fun req -> req.Proxy <- WebProxy("http://proxy.myCompany.com:80", true); req))
In the new version (upcoming release), we are renaming the current Http.Request to Http.RequestString and the current Http.RequestDetailed to Http.Request. This is a breaking change, but we thing it makes much more sense (and fits better with standard .NET naming). If you just want to copy the old file, you can always get the older version of the code from the appropriate branch on GitHub (e.g. Http.fs # tag v1.1.10).
However, I think that supporting HTTP proxies would be a great addition to the library. So the best thing to do would be to fork the project to your GitHub, add the feature and submit a pull request! I think that just adding an optional ?proxy parameter to the two methods and propagating the information to the underlying HttpWebRequestwould be the best way to do this.
The only tricky thing is that Http.Request should work on multiple versions of .NET (including Windows Phone, Silverlight, etc.) so you may need to check which of them actually support specifying the proxy.
If you do not have the time for helping out, then please submit a GitHub issue.
Have you tried overriding the proxy globally with WebRequest.DefaultWebProxy = new System.Net.WebProxy("http://proxy.myCompany.com:80", true)?

Ruby SOAP Client using SAVON not working whereas PHP SOAP client works

Hello there I am testing few web services and I am trying to write a client using SAVON with my WSDL. I have one available operation named log_process and I am trying to access that but getting errors. I have a similar script written in PHP and it is working fine. I have tried
require 'net/http'
require "uri"
require 'savon'
client = Savon.client(wsdl: "http://somedomain.com/projects/shared/abc.wsdl")
#a=client.operations
puts #a
ary={0 =>"art", 1 =>"bac", 2 =>"arr"}
#result = client.call(:log_process, message:{0 =>"asdf", 1 =>"qwer", 2 =>"arr"})
puts #result
and getting following error
raise_soap_and_http_errors!': (SOAP-ENV:Client) Bad Request (Savon::SOAPFault)
My php working solution looks like this
$result = $client->log_process(array(0=>$user_name,1=>$user_pwd,2=>$display_type));
any idea what will be the ruby equivalent to this or am I calling the operation in correct manner?
I know this is late, but I was having the exact same issue trying to set up a soap request using savon to a soap server I have worked with extensively using PHP Soap server. I found another post related to this, and it seem that adding the message_tag option fixed it.
This is because in my case the WSDL was expecting functionNameRequest in the xml, but savon as only sending funcionName by setting message_tag to functionNameRequest the >soap server was able to correctly map the function that was being requested.
This was the thread that helped me out https://github.com/savonrb/savon/issues/520 Relevant code quoted below:
Hi,
I'm just sharing this in case it's useful.
I'm using savon 2.3.0 and I guess the gem had some problems identifying parameters >automatically from my wsdl. I have no idea about SOAP and this is the first time I'm >actually using it.
I'm dealing with TradeTracker's WSDL
With the following code I got it working:
client = Savon.client do
wsdl "http://ws.tradetracker.com/soap/affiliate?wsdl"
namespace_identifier :ns1
end
credentials = {
customerID: 123123,
passphrase: "123123123"
}
response = client.call(:authenticate, message_tag: :authenticate, message: credentials)
Try:
#result = client.call(:log_process, message:["asdf", "asg", "arr"])
In the PHP code, you are sending only 1 parameter, its an array

Resources