0.0
Low commit activity in last 3 years
No release in over a year
HTTP client library for working with SAP OCI compliant servers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.2.17
~> 13.0.3
~> 6.3.1
~> 2.1

Runtime

~> 1.4.1
~> 2.0, >= 2.0.9
~> 0.5.3
~> 1.6.1
 Project Readme

SAP OCI Connect

Test

We use this library to work with eprocurement punchout systems that comply to the SAP OCI 4.0 and 5.0 specification.

Features

SAP OCI Background Search

It's as simple as this:

conn = Faraday.new("http://onlineshop.com/path")
resp = SAPOCI::Connect.search(:get, conn, "toner", "http://return.to/me")
puts resp.status           # => 200
puts resp.body             # => <SAPOCI::Document>
puts resp.env[:raw_body]   # => "<html>...</html>"

You can configure the Faraday connection in all detail. Just be sure to include the SAPOCI middleware. Here's an example:

conn = Faraday.new("http://onlineshop.com/path", params: {"token" => "123"}) do |builder|
  builder.use SAPOCI::Connect::Middleware::FollowRedirects, {cookies: :all, limit: 5}
  builder.use SAPOCI::Connect::Middleware::BackgroundSearch, {preserve_raw: true}
  builder.adapter :net_http
end

Or, use symbols:

conn = Faraday.new("http://onlineshop.com/path", params: {"token" => "123"}) do |builder|
  builder.use :oci_follow_redirects, {cookies: :all, limit: 5}
  builder.use :oci_background_search, {preserve_raw: true}
  builder.adapter :net_http
end

The SAPOCI::Connect::Middleware::FollowRedirects expands on the existing FaradayMiddleware::FollowRedirects middleware in that it forwards cookies and returns some errors like e.g. when a redirect is blank or the maximum number of redirects is reached.

The SAPOCI::Connect::Middleware::BackgroundSearch automatically parses the response body (just like the JSON and XML parser middlewares do), and returns an SAPOCI::Document to look into. Notice that {preserve_raw: true} needs to be passed as well if you want the original HTTP response body in response.env[:raw_body].

Review Faraday for details on connection initiation. We require Faraday version 1.0.1 or later.

Testing

Here's how to test locally:

bundle install
# Start a second console
rake start_test_server
# Back in first console
bundle exec rake test

To test remote OCI punchout shops, use the REMOTE environment variable:

REMOTE="http://remote-site.com/Login.aspx?u=demo&p=secret" rake

Credits

Standing on the shoulder of giants, where giants include:

... and many other contributors. Thanks, guys. You rock!

License

MIT. See LICENSE.