Showing posts with label Web Services. Show all posts
Showing posts with label Web Services. Show all posts

Thursday, December 6, 2018

Class not found when running test case during gradle build

Problem:

I got the exception when I run the test case, which is using the generated WSDL source file, and got "Class not found exception" . Because my test case not able to find the genearted source code from WSDL.


Solution:

I added the below line gradle and its working fine.

sourceSets.test.java.srcDirs = ['.apt_generated/xxx,'src/test/java']



Thursday, February 16, 2017

Chrome throwing 302 Error and Working fine in Internet Explorer

Ago some days back, I got an issue in chrome browser for one service which is returning a status code error 302. I checked the same in REST Client and this also returning error code 302.

But the same service working fine with IE browser. Initially I tried lot of tried with setting header filed cache etc., But nothing worked.

What are the possibilities for 302 status code error and How to handle it ?

The below are some of the possibilities only. But mostly it will be involved within this.

1. There is redirect issue. possibility, you might have used sendRedirect method instead of forward in java.

2. If you have load balancing then definitely there redirect will happen. The way of handling redirect may produce 302 issue.

3. Chrome throwing 302 exception since it have additional security than IE.

4. Check REST client (Chrome web store) older version, it wont produce this 302 error. But latest Rest client will produce 302 error.

5. Firewall also may produce 302 error, but in this case IE also wont work.

6. If you are using client side request through fetch, you add credential= same-origin. It will solve this issue. It will cookies for your request.

7. Finally , You have an option to play around with the below important attributes.
 Access-Control-Allow-Origin : http://www.xxxxxxx.com
Access-Control-Allow-Credentials : true

Friday, March 18, 2016

WSDL checking through SOAP UI Tool

With the help of SOAP UI Tool, we could check our WSDL file. While providing request data , it will display response data, if your wsdl is fine. Else it may through any exception while submitting request to end point.

The below screenshot will explain , how to check wsdl.

Step 1: Create a New SOAP Project
            File -->New SOAP Project --> It will display pop up like below screenshot. Here, you have to provide project name and you must import your project wsdl file.




Step 2: Once you created project, just expand + symbol based on your project method. (In my sample project it is addValue). After expand that, you able to see request1. Click on that. Below pop up will open.


Step 3: The request asking , you should provide input parameter to request xml. After entering input details, click on left corner Green Arrow Icon(Submit End point). It will show the response XML in next screen like below.


Now your WSDL is working fine, if it is not throwing any exception. 

Thursday, March 17, 2016

Soap Web Service Example - Simple Calculator

Hi All, The below is simple SOAP calculator example. I have created this with below technologies.

1. Eclipse Indigo IDE
2. Apache Tomcat 6
3. Apache Axis

Step 1: Create one dynamic project which name is SimpleCalculator


Step 2: Cretae one package like com.ws.calculator and write one Calculator java class with four methods for addition, substration, multiplication and division.




Step 3: Once Calculator class is created, next you need to create web services through Bottom Java bean approach. I was forget to tick (Checkbox) Publish the web Service and Monitor the web service. Please tick it.




 Step 4:  Click Next button, Now you able to see which style you have to follow for soap web service. You can choose document / literal .
 Step 5: After that click Next, continuosuly it will ask click Next. From your Calculator java code Calculator wsdl will be generated, this concept is called Bottom Up. You can see below, generated wsdl file.


 Step 6: Click Launch button, Eclipse browser will open like below.


 Step 7: Now SimpleCalculatorClient code also generated. Click addition(int,int) method. It will ask you provide two inputs. Once you provide inputs , bottom you able to see correct result like below.

Step 8: We know soap will process all request and responses in the XML format only. Below I provided screenshot for requesting addtion method in the XML format.

Step 9: You can see below response result in the XML format for the above request XML.


Thats ALL.  Happy Learning! Any doubts please raise in comment.