Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6555411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:49:02+00:00 2026-05-25T12:49:02+00:00

I built a web service in using Spring framework in Java and have it

  • 0

I built a web service in using Spring framework in Java and have it run on a tc server on localhost. I tested the web service using curl and it works. In other words, this curl command will post a new transaction to the web service.

curl -X POST -H 'Accept:application/json' -H 'Content-Type: application/json' http://localhost:8080/BarcodePayment/transactions/ --data '{"id":5,"amount":5.0,"paid":true}'

Now, I am building a web app using RoR and would like to do something similar. How can I build that? Basically, the RoR web app will be a client that posts to the web service.

Searching SO and the web, I found some helpful links but I cannot get it to work. For example, from this post, he/she uses net/http.

I tried but it doesn’t work. In my controller, I have

  require 'net/http'
  require "uri"

 def post_webservice
      @transaction = Transaction.find(params[:id])
      @transaction.update_attribute(:checkout_started, true);

      # do a post service to localhost:8080/BarcodePayment/transactions
      # use net/http
      url = URI.parse('http://localhost:8080/BarcodePayment/transactions/')
      response = Net::HTTP::Post.new(url_path)
      request.content_type = 'application/json'
      request.body = '{"id":5,"amount":5.0,"paid":true}'
      response = Net::HTTP.start(url.host, url.port) {|http| http.request(request) }

      assert_equal '201 Created', response.get_fields('Status')[0]
    end

It returns with error:

undefined local variable or method `url_path' for #<TransactionsController:0x0000010287ed28>

The sample code I am using is from here

I am not attached to net/http and I don’t mind using other tools as long as I can accomplish the same task easily.

Thanks much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:49:02+00:00Added an answer on May 25, 2026 at 12:49 pm
    url = URI.parse('http://localhost:8080/BarcodePayment/transactions/')
    response = Net::HTTP::Post.new(url_path)
    

    Your problem is exactly what the interpreter told you it is: url_path is undeclared. what you want is to call the #path method on the url variable you declared in the previous line.

    url = URI.parse('http://localhost:8080/BarcodePayment/transactions/')
    response = Net::HTTP::Post.new(url.path)
    

    should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have no experience with web services. Historically I've built client-server systems using proprietary
I'm using eclipse and I have a java web service (rest jax-rs) I also
I have built a Spring 3 MVC driven RESTful web service app. I use
I have tested a web application I have built using MVC 2 on local
I have a web service (built using jaxb/jaxws) that invokes a stateless EJB to
I'm building a traditional ASP.NET Web Service -- the style built using asmx. It's
I have a web service built for SharePoint 2007 that I am trying to
I built a .NET ASMX web service connecting to an SQL Server database. There
I am using jQuery to consume a web service I built, the input is
I'm working on a web application written in Java using the Tapestry 5.1.0.5 framework.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.