Ketan's Home

January 17, 2018

Tips of the Year: The Best Tips of 2017

Filed under: Uncategorized — ketan @ 6:16 PM

Tips of the Week is our weekly peek at some of the best making tips, tricks, and recommendations we’ve discovered in our travels. Check in every Friday to see what we’ve discovered. And we want to hear from you. Please share your tips, shortcuts, best practices, and tall shop tales in the comments below and we might use your tip in a future column.

***

This week, for our last Tips column of 2017, I have assembled some of my favorite tips of the year. Do you have any favorite tips and tool recommendations from 2017? If so, please share them in the comments. And, Happy New Year!

Cutting Perfect Jumper Wires

This tip comes to us by way of our own Make: Video channel and Charles Platt’s

Make: Electronics

. As the video points out, jumper wire kits are color-coded by length of wire. That means that, if you want to breadboard a project where you use red wire for power, black for ground, green for signal, or whatever, you are out of luck. It’s certainly easy enough to cut pieces of wire to make your own jumpers, but it can be a little fussy to get the lengths exactly right. This method the stripping, measuring, and cutting the wires makes it easy to create your own precise set of jumpers color-coded however you wish. It’s probably easiest to just watch the video to see how it works.

Masking Off Gap Fills

We’ve mentioned this tip before and it’s one you should consider for gluing, gap-filling, or any other finishing that might leave material residue where you don’t want it.

Here

, Jimmy DiResta is making picture frames. He wants to gap-fill the joins, but wants to minimize the cleaning/sanding of the filler around the joins. So, he applies painter’s tape to either side of the gap. Then, after you’ve filled the gap and remove the tape, cleaning the area is minimal and easy.

Tape-Flag to Determine Motor Direction

Here’s a simple trick that will save you a lot of aggravation. When working with motor control, in trying to figure out what direction a motor shaft is spinning, make a little flag of tape to affix to the shaft. This makes it unambiguous as to what direction your motor is turning in. [Image from Nuts and Volts.]

Twisting Wire with a Drill

The forever-clever John Edgar Park posted a quick-vid on Instagram this week reminding me of this little trick: using a drill for twisting up wire pairs. Note how he’s chucked the wires. I’ve seen people make and chuck little hooks into their drills but you really only need to do what John has done here.

Acetate Over-Notes

John Edgar Park

shared this tip with us a while ago, but I bumped into it again this week. When figuring out project wiring or other parts of a project design that might be subject to change, tape sheets of acetate over your design and mark on that with a dry erase marker. That way, you can continue to change things around until you’re confident that you have the arrangement you desire.

Digging Post Holes with a Shop Vac

Our pal Jake von Slatt is at it again. Several weeks ago, we shared his tip on using 2-way tape to hold small nuts on your fingertips for getting them in hard to reach places. This week, he offered this gem on Instagram, using a strong shop vac to “dig” post holes. He was pretty jazzed by how well it worked.

Pre-Gluing End Grain

In this recent

Make Something

video on making

relatively simple but swanky-looking picture frames

, David reminds us of a great tip when dealing with end-grain wood that you’re planning to glue. The exposed grain of the wood can wick up a lot of the glue you apply to join it, weakening the resulting join. To prevent this, you simply pre-glue the end-grain to be joined. That glue will wick into the wood so that the glue you apply on top of that to create the actual join will stay put and will have more surface area to adhere to.

Making a Retractable Pocket Saw Blade

You can create a retractable pocket saw blade by removing the blade from a retractable utility knife and using it as a template to cut a suitably-sized hacksaw blade to size. Then drill a hole where the thumb-handle mounts and replace it into the utility knife housing. You now have a retractable pocket saw.

CA Gluing Hinges

Here’s a great one from Izzy Swan. In a

recent video

where he builds a gorgeous wooden box for a wooden watch, he uses CA glue and an activator to temporarily hold on hinges before gluing. In the video, also note how he sprays down the activator first and then he glues and places the hinges.

3D Printing Custom Sanding Grips

tie

tie

Bob Clagett of

I Like to Make Stuff

offers this brilliant tip on

3D printing custom standing grips

. Using 3D design software, you can quickly and easily create grips that are designed to conform to a specific surface on your project. If you have 3D designed and printed the thing you’re wanting to sand, you can even use the negative space information to create grips designed to sand inside of tough places. And as Bob points out, since resolution doesn’t mean much here, you can print at the lowest resolution to make print time much quicker. Which is a tip in itself, to always consider the application of your prints and adjust print resolution accordingly.

Bending PVC with Hot Sand

needle

needle

Make:’s

Senior Video Producer, Tyler Winegarner, hipped me to this tip. On the

Darbin Orvar channel

, Linn shows how she experimented with

heat-bending PVC piping

. After trying to heat the outside of the pipe to bend it, she decided to try filling the insides of the pipe with hot sand. The results are impressive. For small-to-mid diameter PVC pipe, it looks like a great way to twist and form piping into whatever shapes you desire.

Clamp as Caulking Gun

painting

painting

On Twitter, Combustible Props‏ (@MrCombustible) posted the above image and the tweet: “Hehe, I’ve been there. When you realize the workshop doesn’t have a calking gun… 😀 Photo by @dev_dsp.” His image was in response to an Adam Savage (@donttrythis) tweet about making this gorgeous DIY compass out of a coat hanger and a paper clip when he was away from his shop, wanted to do some mechanical drawings (for a spacesuit costume he’s working on), and didn’t have a compass.

Paint Mixing Balls

This week I bought some hobby paints from a scale modeling supply company called

AMMO of Mig Jimenez

. When I got the paints, which come in eyedropper-style bottles, I was thrilled to discover that each bottle has an agitator ball inside (as found in spray cans). Why on Earth don’t other hobby paints have these? I have had so many paints, expensive hobby paints, go lumpy and harden in the jars. It would be so useful to have these ball bearings inside to help keep the paint well-mixed. I did a search to find this type of stainless steel ball and found plenty. Here are the ones I

ordered on Amazon

. To search the web for them, use terms like “stainless steel burnishing balls,” “tumbling shot,” and “nail polish agitator balls.” While I was at it, I also ordered

10 eyedropper bottles

(for $2.34). I’m going to start transferring my paints from snap-top pots to these for better air-proofing.

“Finishing” Solder Joins

By way of the always-recommended Maker Update, Donald Bell introduced me to this technique for finishing off the solder points on a PCB. As Donald points out, many PCBs are so lovely these days, works of art in themselves, that you might want to have a more aesthetic finish to your populated circuit boards. To do this, rather than side-cutting the little solder mounds at the top of the mound, with this method, you cut as close to the board as possible and reheat and re-plump the points with a hit of the solder tip and some solder. What you end up with are these handsome little solder pillows. UPDATE: Donald has posted an Instructable with more details on this technique.

Adding Color to Laser Engraving

On the

YouTube

channel,

Laser Wood Minnesota

, they offer

this great tip

for coloring fine-detail laser engraving. Used a dye meant for coloring epoxy (such as TransTint), mixed with denatured alcohol. It’s easy to apply and you simply wipe the surface clean which leaves only the deeper engraved surfaces with dye in them.

Making Plastic Rivets with a Glue Gun

Barb Makes Things

is one of my recent favorite maker channels. The video she

posted in late November

is an announcement about how she is going to change things up a bit going forward, but at the end of the video, there is a clip of her using the nozzle of her hot glue gun to create plastic rivets. Just press the plastic to the side of the hot nozzle, and bam, you have a rivet head. Great tip!

Super Clean Cable Splicing

needle

needle

In this fantastic

quick technique tutorial

, Becky Stern shows you the best way of stripping, soldering, and shrink-tubing a cable splice. The trick is to offset the wire joins so that, when you add heat-shrink to the individual wires, and then the entire splice, you don’t get a big lump in the cable.

from MAKE Magazine https://makezine.com/2017/12/29/tips-of-the-year-the-best-tips-of-2017/

Easing into Fusion 360 CAM with Evan & Katelyn

Filed under: Uncategorized — ketan @ 6:06 PM

Autodesk’s Fusion 360 software is complicated enough, but even if you feel really competent in the modeling part of the software, you’d be forgiven for feeling completely overwhelmed by the Fusion 360 CAM (Computer Aided Machining) interface. CAM is where you set up the instructions for your CNC machine so it knows how to turn your design into a physical object. The terminology is laden with plenty of machinist’s jargon, and every single tool or function has well over 100 options. It’s easy to get lost. But the amazing YouTube duo of Evan & Katelyn have put together a fantastic primer on getting your feet wet with this feature of Fusion 360 to take your CNC machining to the next level.

from MAKE Magazine http://ift.tt/2Eu6JuX

January 15, 2018

Pi Weather Lamp Puts Lava Lamps To Shame

Filed under: Uncategorized — ketan @ 3:22 PM

Pi Weather Lamp Puts Lava Lamps To Shame

Representing the weather on an LED lamp in a manner that’s easy to interpret can be difficult, but [Gosse Adema]’s weather/matrix lamp makes it not only obvious what the weather is but also offers a very attractive display. For rain, drops of light move downward, and for wind, sideways. The temperature is shown using a range of colors from red to blue, and since he is situated in the Netherlands he needed snow, which he shows as white. A rainy, windy day has lights moving both down and sideways with temperature information as the background.

Weather matrix lamp

To implement it he mounted LED strips inside a 3D printed cylinder with reflectors for each LED, all of which fitted into a glass cylinder taken from another lamp purchased online. The brains of it is a Raspberry Pi Zero W housed in the bottom along with a fan. Both the LEDs and the fan are controlled by the Pi. He took a lot of care with power management, first calculating the current that the LEDs would draw, and then writing Python code to limit that draw. However upon measurement, the current draw was much lower than expected and so he resized the power supply appropriately. He also took care to correctly size the wires and properly distribute the power with a specially made power distribution board. Overall, we really like the thorough job he’s done.

But then again, what’s not to like about [Gosse]’s projects. In the area of lighting, he’s dazzled us with WiFi controlled Christmas tree ornaments, but he’s also delighted us with a Prusa i3 based LEGO 3D printer on which he printed LEGO parts and then made a special extruder for printing chocolate.

from Hack a Day http://ift.tt/2B0Ktq0

January 13, 2018

Article: Five Things Every Developer Should Know About Software Architecture

Filed under: Uncategorized — ketan @ 9:32 AM

Given the distributed nature of the software systems we’re now building, and the distributed nature of the teams building them, it’s more important than ever to understand the basics of software architecture. As a short introduction to the topic and to debunk some myths, here are five things that every software developer should know about software architecture.

By Simon Brown

from InfoQ http://ift.tt/2mcCotX

January 11, 2018

restQL, a Microservices Query Language, Released on GitHub

Filed under: Uncategorized — ketan @ 10:37 PM

restQL, a query language for microservices, is now available as an open-source project on GitHub. The restQL language is intended to simplify common scenarios for client-side access to RESTful microservices, including multiple parallel calls and chained calls. restQL was created to avoid some limitations of the more well-known data querying and management frameworks Falcor and GraphQL.

By Thomas Betts

from InfoQ http://ift.tt/2CRnWOm

January 9, 2018

Spring SOAP with XML Example

Filed under: Uncategorized — ketan @ 6:23 AM

Web services are the distributed computing mechanism designed to work with open standards and protocols, thus facilitating interoperability among disparate systems. Simple Object Access Protocol (SOAP) was developed by Microsoft as an improvement over the existing technologies like Distributed Component Object Model (DCOM), Common Object Request Broker Architecture (CORBA) and Java Remote Method Invocation (RMI) that relied on binary and proprietary formats. A SOAP message chiefly uses the eXtensible Markup Language (XML) for the message format, HyperText Transfer Protocol for the transport protocol and the interface definition in a file using the Web Services Definition Language (WSDL). Other formats and protocols can also be used with SOAP. In summary, SOAP is platform-independent, has built-in error handling and is extensible providing support for security, federation, reliability and other aspects.

1. Introduction

In this article, we will show how to implement a SOAP web service with XML request and response in a Spring Boot application. Using Spring framework’s Dependency Injection and annotation based support in conjunction with the maven plugin jaxb2-maven-plugin, the whole process of extracting XML from the SOAP input, mapping to Java objects and returning the SOAP response becomes very easy so that developers can focus on implementing business logic and unit testing the application.

2. Application

The application we will develop is a web service for calculating the surcharge to be applied to an order. An order has the fields id, value, payment_method and a customer. The fields of customer are name (“first”, “last”) and an address, which in turn has the fields street (“line” which can take values 1 and 2), city, postal code and country.

The surcharge is calculated as a percentage. If the customer’s country is “US”, surcharge is 10%, otherwise it is 15%. If payment method is credit card, indicated by CC, the surcharge will be increased by 3%. If the order value is greater than 1000, a discount of 1% will be given. A discount is a negative surcharge and since the calculation is very simple, it is kept in this service. In real world applications, discounting will be a service of its own. Since all surcharges for this application are in percentages, we will not consider the % symbol either in the input or output and will be returned as an int.

3. Environment

I have used the following technologies for this application:

  • Java 1.8
  • Spring Boot 1.5.9
  • JAXB2 Maven plugin 1.6
  • Maven 3.3.9
  • Ubuntu 16.04 LTS

4. Source Code

Typically you would get a sample XML file from your business analyst or client showing all the elements and data used to send as input to the web service. The following snippet shows a sample order in XML format.

sample1.xml

<?xml version="1.0" encoding="UTF-8"?>
<order>
    <id>S12345</id>
    <value>1250</value>
    <payment_method>CC</payment_method>
    <customer>
        <name part="first">Nancy</name>
        <name part="last">Smith</name>
        <address>
            <street line="1">41 Earnest Road</street>
            <street line="2">Rotamonte Park</street>
            <city>Koregon</city>
            <postalcode>12345</postalcode>
            <country>UK</country>
        </address>
    </customer>
</order>

The first step in implementing the SOAP web service is to create an XML schema definition file. We will name it surcharge.xsd and it can be either hand written or generated with a plugin. I have used the online tool http://ift.tt/1DNcRwi. The generated xsd shows a few errors in Eclipse, which had to be corrected. For example, the error for name element is:

Element 'name' has both a 'type' attribute and a 'anonymous type' child. Only one of these is allowed for an element.

The generated XML is:

<xs:element name="name" maxOccurs="unbounded" type="xs:string">
    <xs:complexType>
        <xs:attribute name="part" type="xs:string"></xs:attribute>
    </xs:complexType>
</xs:element>

It has to be corrected to

<xs:element maxOccurs="2" name="name">
    <xs:complexType>
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="part" type="xs:string" />
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:element>

In general, the xsd file has two patterns to be applied:
1) element – complexType – sequence – element – complexType – sequence – element / element
2) element – complexType – simpleContent – extension – attribute

Your xsd file will be a combination of these two patterns to cater to any nested XML data. The final corrected xsd file including the response element is shown below:

surcharge.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://ift.tt/tphNwY"
targetNamespace="http://ift.tt/2mhqqPD"
xmlns:tns="http://ift.tt/2mhqqPD"
elementFormDefault="qualified">

    <xs:element name="SurchargeRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="order">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="id" type="xs:string"></xs:element>
                            <xs:element name="value" type="xs:int"></xs:element>
                            <xs:element name="payment_method" type="xs:string"></xs:element>
                            <xs:element name="customer">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element maxOccurs="2" name="name">
                                            <xs:complexType>
                                                <xs:simpleContent>
                                                    <xs:extension base="xs:string">
                                                        <xs:attribute name="part" type="xs:string" />
                                                    </xs:extension>
                                                </xs:simpleContent>
                                            </xs:complexType>
                                        </xs:element>
                                        <xs:element name="address">
                                            <xs:complexType>
                                                <xs:sequence>
                                                    <xs:element maxOccurs="2" name="street">
                                                        <xs:complexType>
                                                            <xs:simpleContent>
                                                                <xs:extension base="xs:string">
                                                                    <xs:attribute name="line" type="xs:string" />
                                                                </xs:extension>
                                                            </xs:simpleContent>
                                                        </xs:complexType>
                                                    </xs:element>
                                                    <xs:element name="city" type="xs:string"></xs:element>
                                                    <xs:element name="postalcode" type="xs:int"></xs:element>
                                                    <xs:element name="country" type="xs:string"></xs:element>
                                                </xs:sequence>
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="SurchargeResponse">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="surcharge" type="xs:int" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

</xs:schema>

The target namespace is specified as “http://ift.tt/2mhqqPD”. With this, a package called org.javacodegeeks.webservices.soap.surcharge.generated will be created during compile time and the classes generated from the xsd file will be placed there.

Since this is a maven-based project, all the project-level settings and dependencies are given in pom.xml file.

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/VE5zRx">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.javacodegeeks.webservices.soap</groupId>
    <artifactId>surcharge</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>surcharge</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>
        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
         </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>jaxb2-maven-plugin</artifactId>
                 <version>1.6</version>
                 <executions>
                     <execution>
                         <id>xjc</id>
                         <goals>
                             <goal>xjc</goal>
                         </goals>
                     </execution>
                 </executions>
                 <configuration>
                     <clearOutputDir>false</clearOutputDir>
                     <schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
                     <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
                 </configuration>
             </plugin>
         </plugins>
    </build>
</project>

The configuration for jaxb2-maven-plugin specifies that the output directory should not cleared when the classes are generated, the schema file is located in src/main/resources directory and that the output directory where the package should be created is src/main/java.

SurchargeApplication.java

package org.javacodegeeks.webservices.soap.surcharge;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SurchargeApplication {

	public static void main(String[] args) {
		SpringApplication.run(SurchargeApplication.class, args);
		
		System.out.println("SurchargeApplication now running....");
	}
}

This is the main class of the application that runs on the default Tomcat container of Spring Boot at port 8080.

SoapConfig.java

package org.javacodegeeks.webservices.soap.surcharge.config;

import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.config.annotation.EnableWs;
import org.springframework.ws.transport.http.MessageDispatcherServlet;
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
import org.springframework.xml.xsd.SimpleXsdSchema;
import org.springframework.xml.xsd.XsdSchema;

@EnableWs
@Configuration
public class SoapConfig {
	@Bean
	public XsdSchema surchargeSchema() {
		return new SimpleXsdSchema(new ClassPathResource("surcharge.xsd"));
	}
	
	@Bean(name = "surcharge")
	public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema surchargeSchema) {
		DefaultWsdl11Definition definition = new DefaultWsdl11Definition();
		definition.setPortTypeName("SurchargePort");
		definition.setTargetNamespace("http://ift.tt/2mhqqPD");
		definition.setLocationUri("/ws");
		definition.setSchema(surchargeSchema);
		return definition;
	}
	
	@Bean
	public ServletRegistrationBean messageDispatcherServlet(ApplicationContext context) {
		MessageDispatcherServlet messageDispatcherServlet = new MessageDispatcherServlet();
		messageDispatcherServlet.setApplicationContext(context);
		messageDispatcherServlet.setTransformWsdlLocations(true);
		return new ServletRegistrationBean(messageDispatcherServlet, "/ws/*");
	}

}

This class sets up the configures all the beans required as the application infrastructure. @EnableWS enables all the Spring Java web services configuration defined in WsConfigurationSupport class to be imported to our application configuration. It provides facilities for endpoint mapping to annotated controllers, adapters and exception handlers.

First, in the surchargeSchema method, the surcharge.xsd file is used to configure a SimpleXsdSchema bean. Next, in the defaultWsdl11Definition method, this bean set as the schema in a DefaultWsdl11Definition with the name surcharge. Last, in the messageDispatcherServlet method, a MessageDispatcherServlet is created to take the ApplicationContext and then used to create a ServletRegistrationBean to handle the URI path /ws.

SurchargeEndpoint.java

package org.javacodegeeks.webservices.soap.surcharge.endpoint;

import org.javacodegeeks.webservices.soap.surcharge.generated.SurchargeRequest;
import org.javacodegeeks.webservices.soap.surcharge.generated.SurchargeResponse;
import org.javacodegeeks.webservices.soap.surcharge.service.SurchargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

@Endpoint
public class SurchargeEndpoint {

	@Autowired
	SurchargeService service;

	@PayloadRoot(namespace = "http://ift.tt/2mhqqPD", localPart = "SurchargeRequest")
	@ResponsePayload
	public SurchargeResponse processCourseDetailsRequest(@RequestPayload SurchargeRequest request) {

		SurchargeResponse response = new SurchargeResponse();

		int surcharge = service.calculateSurcharge(request.getOrder());
		response.setSurcharge(surcharge);

		return response;
	}

}

This class has a SurchargeService bean auto-wired. With the @PayloadRoot annotation, we mark the method processCourseDetailsRequest as the handler for the incoming request. The @ResponsePayload annotation marks that the return value should be bound to the response payload.

In the processCourseDetailsRequest method, a SurchargeResponse object is instantiated. The service bean’s calculateSurcharge method is called passing in the Order object from the SurchargeRequest input. The calculated surcharge returned from the call is set into the SurchargeResponse object that is then returned.

SurchargeService.java

package org.javacodegeeks.webservices.soap.surcharge.service;

import org.javacodegeeks.webservices.soap.surcharge.generated.SurchargeRequest.Order;
import org.springframework.stereotype.Component;

@Component
public class SurchargeService {
	
	public int calculateSurcharge(Order order) {
		
		int surcharge = 15;
		if (order.getCustomer().getAddress().getCountry().equals("US"))
			surcharge = 10;

		if (order.getPaymentMethod().equals("CC"))
			surcharge += 3;

		if (order.getValue() > 1000)
			surcharge -= 1;

		return surcharge;
	}
}

This class has a method calculateSurcharge that implements the business logic of calculating the surcharge for a given order, as given in Section 2 above.

5. How To Run and Test

In a terminal window go to the project root folder and enter

mvn spring-boot:run

There are many client applications like SoapUI or Wizdler that you can use to invoke this service. I have used Postman app. The test request data is formed by just a few changes to the sample XML file we started with.

test1.xml

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://ift.tt/sVJIaE"
 xmlns="http://ift.tt/sVJIaE">
    <soapenv:Body>
        <SurchargeRequest xmlns="http://ift.tt/2mhqqPD">
            <order>
                <id>S12345</id>
                <value>1250</value>
                <payment_method>CC</payment_method>
                <customer>
                    <name part="first">Nancy</name>
                    <name part="last">Smith</name>
                    <address>
                        <street line="1">41 Earnest Road</street>
                        <street line="2">Rotamonte Park</street>
                        <city>Koregon</city>
                        <postalcode>12345</postalcode>
                        <country>UK</country>
                    </address>
                </customer>
            </order>
        </SurchargeRequest>
    </soapenv:Body>
</soapenv:Envelope>

Given below is the screen shot of Postman showing the input soap XML and the response from the web service.

Output showing sample SOAP Request and Response of SurchargeService.

Since the order country is not “US”, payment method is “CC”, and the value is greater than 1000, the surcharge calculated is 15 + 3 -1 = 17, which is returned in the response.

6. Summary

In this article, we have seen how to use Spring framework in conjunction with maven plugin to implement a SOAP web service that take XML request and returns an XML response. We have also seen how to start from a sample XML to generate the XML schema definition and from there use the maven plugin and Spring annotations to transform the XML input to Java objects that are then used to execute the business logic.

7. Useful Links

Following resources will be very useful to get additional information and insights on concepts discussed in this article:

8. Download the Source Code

Download

You can download the full source code of this example here:

surcharge.zip

from Java Code Geeks http://ift.tt/2CRdiuZ

January 7, 2018

Scrap a Hard Drive, Build a Rotary Encoder

Filed under: Uncategorized — ketan @ 11:19 AM

Scrap a Hard Drive, Build a Rotary Encoder

There’s something to be said for the feel of controls. Whether it’s the satisfying snap of a high-quality switch or the buttery touch of the pots on an expensive amplifier, the tactile experience of the controls you interact with says a lot about a device.

[GreatScott!] knows this, and rather than put up with the bump and grind of a cheap rotary encoder, he decided to find an alternative. He ended up exploring hard drive motors as encoders, and while the results aren’t exactly high resolution, he may be onto something. Starting with a teardown of some old HDDs — save those magnets! — [Scott!] found that the motors fell into either the four-lead or three-lead categories. Knowing that HDD motors are brushless DC motors, he reasoned that the four-lead motors had their three windings in Wye configuration with the neutral point brought out to an external connection. A little oscilloscope work showed the expected three-phase output when the motor hub was turned, with the leading and lagging phases changing as the direction of rotation was switched. Hooked to an Arduino, the motor made a workable encoder, later improved by sending each phase through a comparator and using digital inputs rather than using the Nano’s DACs.

It looks like [GreatScott!]’s current setup only responds to a full rotation of the makeshift encoder, but we’d bet resolution could be improved. Perhaps this previous post on turning BLDC motors into encoders will help.

from Hack a Day http://ift.tt/2D3GcVC

Toy R/C Car Upgrade to Hobby Grade Parts

Filed under: Uncategorized — ketan @ 10:05 AM

Toy R/C Car Upgrade to Hobby Grade Parts

[HobbyPartz] wanted his toy grade Radio Controlled (R/C) to drive a bit more like the real thing, so he upgraded it to hobby grade electronics.

If you didn’t know, there’s a pecking order in the R/C world. There are the toy grade cars which you can find at your local big box store, and the hobby grade cars, which grace the shelves of the local hobby shop. Toy cars often come with great looking shells – Corvettes, Lamborghinis, Porsches,  or even Ferraris. It often seems like the manufacturer spent all their money licensing and molding the shell though because the mechanics and electronics leave a lot to be desired. You could pull the body off and put it on a hobby grade R/C car, but that could get expensive. It also can be tricky to find a car with exactly the right width and wheelbase.

[HobbyPartz] had just this problem with a great looking Ferrari Enzo model that you can see in the video below the break. As expected, the pretty shell hid some really cheap electronics underneath. This is easily fixed by pulling and tossing everything electronic. The steering system was non-proportional — only full left or right turns. He removed the existing steering hardware and hot glued in a standard R/C servo. Once the servo is in position, it’s  easy to connect the linkages to the wheels themselves.

On the drive side, the receiver and speed control were replaced with a 2.4GHz receiver. A brushed electronic speed control gave the car a proportional throttle. Only the original drive motor remained stock.

Once back together, the car performed much better than it ever could have in stock form. It obviously is no speed or performance demon. However, a scale model like this would never make a good racer. If you want to know more about commodity radio control systems, check this out.

from Hack a Day http://ift.tt/2q9errV

January 6, 2018

ATtiny Chip Abused in RFID Application

Filed under: Uncategorized — ketan @ 5:24 PM

ATtiny Chip Abused in RFID Application

One of Atmel’s smallest microcontrollers, the ATtiny, is among the most inexpensive and reliable chips around for small applications. It’s also one of the most popular. If you don’t need more than a few inputs or outputs, there’s nothing better. As a show of its ability to thrive under adverse conditions, [Trammell Hudson] was able to shoehorn an ATtiny into an RFID circuit in a way that tests the limits of the chip design.

The RFID circuit only uses two of the ATtiny’s pins and neither of which is the ground or power pin. The ATtiny is equipped with protective diodes on its input pins, and if you apply an AC waveform to the input pins, the chip is able to use the leakage current to power itself. Once that little hurdle is crossed, the ATtiny can do the rest of its job handling the RFID circuitry.

This project takes a deep dive into the internals of the ATtiny. If you’ve ever wondered what was going on inside of everyone’s favorite tiny microcontroller, or if you’re looking for an RFID circuit that keeps parts counts to an absolute minimum, this is the project for you.  The ATtiny is more than just a rugged, well-designed chip, though. It’s capable of a lot more than such a small chip should be able to.

Thanks to [adnidor] for the tip!

from Hack a Day http://ift.tt/2CXuKe0

Automatic Dust Collection for the Whole Shop

Filed under: Uncategorized — ketan @ 5:10 PM

If you’ve got a woodworking area, or even if you’ve just got something that really churns out dust like a belt sander or table saw, there’s an excellent chance you hate sawdust with a passion. It gets all over your clothes, jams up everything mechanical, and as a fun little bonus can be explosive if not handled properly. Thankfully newer tools tend to come with their own dust collection bags (back in the old days, you weren’t really a man unless you were coughing up wood fibers), but if you’ve got a half a dozen tools with half a dozen different dust bags you’ve got to empty, that can get pretty annoying.

Especially if you take woodworking as seriously as [Brad Wright] does. Over on his YouTube channel [DIY Builds], he quickly runs through the construction of a whole-shop dust collection system with some very neat features. Not everyone needs a system this intricate, but the tips and tricks he shows off during the build are great and can certainly be adapted to less grandiose setups.

Dust collection connector with closeable gate
One of the scratch-built gates.

[Brad] goes into a bit more detail in this gallery, revealing that the heart of the build is a Harbor Freight dust collection system that he modified into a cyclone separator. Big chunks fall down into the 55 gallon bucket, and what’s left gets blown out of the shop via a louvered vent through an exterior wall. An intricate system of 4 inch PVC pipe is then used to connect up each individual machine’s dust collection port. Even individual hand sanders get into the act via a three way manifold. His table saw lacked a dust port, so he enclosed the motor with a piece of plywood and made his own.

One of the most interesting aspects of the build is the scratch-built blast gates. These are essentially valves which open and close the different sections of the PVC where they mate to the individual stations. This prevents the dust collection system from wasting suction by trying to pull from all the stations at once when only one is in use at any given time. [Brad] even wired up the blast gates with switches that will turn the dust collection system on when the gate is open, and off when it’s closed.

This isn’t the first time we’ve covered the lengths people will go to rid their shop of dust. Cyclone dust separators are an especially popular build, using everything from sheet metal to 3D printed parts.

Filed under: home hacks, Tool Hacks

from Hack a Day http://ift.tt/2qtwOI5

Older Posts »

Blog at WordPress.com.