This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAR files / Maven structure for Spring xsdtojava convertion

 
Pardha Reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I need to consume the restful service using spring. I have an xsd file. I need the right spring jar file(groupId / artifact Id) to convert from xsd to java. Please let me know if need any other jar files that i need to place in maven structure related to spring.

Thanks
Pardha
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DO you mean you want to use JAXB? JAXB is part of core java, and you don;t need additional jars
 
Pardha Reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My requirement is to use spring framework to call a rest service. For that i have a xsd. I need to generte xsdtojava using spring restful service. I need to create a maven dependency for that. I am looking for the right jar(groupId / Artifact Id) file to add in maven. The reason i need to use that is i have some HTTP GET request and basic http authentication etc and want to go with spring as per the project standard.
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need JAX-WS as shown here You need to add dependency to spring-web

Are you using spring bill of materials (spring-bom) in your project? If you do, all you need to do is add


Otherwise you will have to find out which spring-web is compatible with your spring version.
 
H Paul
Ranch Hand
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to what has been said.

Use org.springframework.web.client.RestTemplate;

Link for spring 4.x
http://docs.spring.io/spring/docs/current/spring-framework-reference/pdf/spring-framework-reference.pdf

Read
21.10 Accessing RESTful services on the Client
 
Pardha Reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jayesh and Paul. This helped me to move forward.
 
Pardha Reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one more question in addition to this. I used the RestTemplate.getForObject for restful service call. But i need to use HTTP basic authentication (RFC 2617). Is it possible with RestTemplate. I saw some method named RestTemplate.exchange. Please suggest.
 
H Paul
Ranch Hand
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Yes. Either you:

A. config basic auth at httpClient when you create RestTemplate
I have not set up this. But you can. Just Google or check Apache HttpClient

B. add basic header to Request header: I did a quick test and worked for me.

 
Pardha Reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Awesome. This helped me to build the code. I made just few changes as per the libraries i am using and in my case response is XML.

Thanks a lot for providing such a simple code.
 
Pardha Reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing some issue in the code at line Base64.getEncoder().encodeToString("tomcat:tomcat".getBytes()); in run time.

As i am using 1.6.x cersion of jdk, i used Base64.encode("tomcat:tomcat"); The base64 that i am using is from org.apache.xmlbeans.impl.util.Base64.

This is giving exception during runtime. This is not going to any exception or so. But as per the logs it is breaking at this line.
No compilation issues, no issues while testing from junit. Issue only at runtime.

I saw couple of online forums that this is an issue but didn't find the solution.

What third party package supports this now for jdk1.6.x version.

Thanks

 
H Paul
Ranch Hand
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(This is how I do: Google for java encode base64)


1. Base64 is since jdk 1.8

2. For jdk 1.6, Use javax.xml.bind.DatatypeConverter.printBase64Binary method
(parseBase64Binary)

from this url http://java-performance.info/base64-encoding-and-decoding-performance/
1. Read: JDK Base64 implementations
2. Read: Third party Base64 implementations

Good luck.
 
Pardha Reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Little late in reply. That worked with org.apache.xerces.impl.dv.util.Base64.

Thanks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic