Naren Mane

Greenhorn
+ Follow
since Mar 02, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Naren Mane

Hi Robinson,

Check the code below which I wrote and I got response as "<html><head><title>504 Gateway Timeout</title></head><body><h1>Gateway Timeout</h1>
<p>Server error - server 208.73.210.29 is unreachable at this moment.<br><br>Please retry the request or contact your adminstrator.<br></p>
</body></html>"




Just see if this helps. I've used HttpClient-4.1.2.

Thanks.
13 years ago
Hi Renjith,

WELCOME. You can call webservice easily by using WSDL2Java tool of AXIS2 WS engine. Have a look here http://axis.apache.org/axis2/java/core/.

Thanks.
13 years ago
Hi,

You are welcome Shasi.

1) When you add "?wsdl" to webservice URL and hit it in a browser what you see is a service contract which is also called as WSDL file. It is just a view file mentioning all the bindings, data, apis etc etc.

2) And a webservice url without a "?wsdl" is a service with which data is sent in actual.That is the endpoint URL to which request/data is posted and user receives response accordingly.

Thus if you hit a ws url with "?wsdl", will return you contract and is not a valid service url.It is document URL.


Thanks.
13 years ago
Hi ,

Here is a piece of code to parse attribute values. This code is written using JDOM parser. Hope it helps.
Please note that code is written considering example provided by you.




Thanks.
13 years ago
Hi,

1) As I can see that you have WSDL url with you then why are you digging with SAAJ api? If you are aware of AXIS2 , you can directly generate java stub from your wsdl and then just fire method you want to and obtain response. SAAJ apis are not that reliable.

2) Did you try mentioning endpoint url without "?wsdl" ?
Did you verify that your SOAP request is getting constructed as expected and accurately?
Also you can send your soap message directly through a URLConnection.

Provide SOAP request you are sending (One from SOAPUI and one constructed in your code).



Thanks.
13 years ago
Hi,

Why don't you try jdom parser, I think it is a good and is developed on top of SAXParser. I've experienced few problem with SAXParser and by using jdom I was able to get around with those problems. It is a pretty parser.

Thanks.


13 years ago
Hi,

Can you share some more info like piece of code you are using or web service URL you are hitting so that I can check what is going wrong.

Thanks.
13 years ago
]Hi,

Against CLASSPATH environment variable you should add path as "D:\SWs\apache-tomcat-7.0.2-windows-x86\apache-tomcat-7.0.2\lib\*;". This works for me....always. Just try this.Here you should replace "D:\SWs\apache-tomcat-7.0.2-windows-x86\apache-tomcat-7.0.2\lib" with path of tomact on your system.
13 years ago

John Juliciana wrote:i have a requirement to read a xml from a 3rd party which is sent via xml over http in the request body and post it to a different WEB service. I have to write a web service to capture that XML and post it. How do i read the XML which comes in the request body and post it using Axis? Im new to web services and need help on this. i have a setup axis 2 and apache successfully.



Any help is highly appreciated

Thanks in advance

John



Hi John,
Apache axis2 contains a tool called wsdl2java which generates stub(java classes) from wsdl. This stub will contain methods which are mapped to wsdl methods. In each method you'll find local variable called "env". On this "env" variable if you invoke getBody() call (i.e. env.getBody()) then it will return you SOAP request body(xml) sometimes it may be formatted to some notation(like '<' would be replaced with '<') , in such case you may need to apply your own logic to parse such notations.

Let me know if I'm not clear.

Thanks.
13 years ago
Hi Jitesh,

OK as you told you are using a wsdl to generate java classes, then one approach to see soap request and response logs is to use APACHE AXIS2 to generate java stubs(i.e. use wsdl2java tool).
*******************************************************************************************************
This java stub will contain auto-generated methods that are mapped to wsdl you used to generate java stub. In each method you will find something like :


org.apache.axiom.soap.SOAPEnvelope env = null;
env = toEnvelope(.....some auto-generated signature here.....);
//Add sysout to print SOAP request log
System.out.println("SOAP Request: "+env.getBody());
.....
.....
.....
org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();
//Add sysout to print SOAP response log
System.out.println("SOAP Response: "+_returnEnv.getBody());

*******************************************************************************************************
Remember this logic is feasible only if you have a java stub generated using wsdl2java tool from Apache Axis2.
Let me know if this approach helps you .
13 years ago
Hi Jitesh,

Let us see if this approach helps you.

You wrote that you are consuming a webservice in your code.
My question is : Are you consuming through a wsdl or it is a restful-ws ?
********************************************************************************************************
If you have a wsdl then one of the easiest way is to use wsdl2java tool in Apache Axis2.
Using this wsdl2java tool you can generate wsdl-mapped java classes(i.e. stub), which you can use in your client code.
One more important advantage with this approach is within this stub you can put sysouts to print the soap requests and responses.

Or you can obtain wsdl by appending "?wsdl" to your webservice URL. If you put this entire URL in IE or firefox you should see a wsdl doc. If you go successful then you can use same URL to generate java stubs.
********************************************************************************************************
And if you are using restful-ws then approach would be different one .
********************************************************************************************************
So first clarify on the things above then we can proceed further.
13 years ago
Hi Dominik,

You can use Apache Axis2 to generate java classes(stubs) from a wsdl. This would be very simple and easy to understand if you're thinking of writing a client. Axis2 contains a tool called WSDL2JAVA which creates wsdl-mapped java classes (i.e. Stub).
Using this stub you can simply invoke service you want and then whatever response you get for that request, you can map that to bean you created.

Also this WSDL2JAVA tools provides various data binding option. Just visit "http://axis.apache.org/axis2/java/core/docs/quickstartguide.html" . It will give you basic idea of using wsdl2java tool and some more info.It contains very useful info.

In my opinion this is very simple and easiest approach if you have a wsdl ready.
13 years ago
If you want to do like java to xsd then use JiBX. Easiest way to do so, in my opinion. You don't need to write any "Xml" annotations in your java class.
13 years ago

Kumar Gaurav wrote:Hi All,

Using JAXB i have to create XML file for a Java object, which i am able to create, below is the code :

@XmlRootElement (name="employee")
@XmlAccessorType (XmlAccessType.FIELD)
public class Employee implements Serializable {

@XmlElement
private String name;
@XmlElement
private String age;

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}

public Employee () {

}
public Employee (String name, String age) {
this.name = name;
this.age = age;
}

public void addPlaceDetail (PlaceDetail detail) {

if (null == placeDetail){

placeDetail = new ArrayList<PlaceDetail>();
}
placeDetail.add(detail);
}

public static void main (String[] args) throws JAXBException, IOException {


Employee employee = new Employee("Nitish","25")

JAXBContext context = JAXBContext.newInstance(Employee.class);
FileWriter writer = new FileWriter("D://EmpXML.xml";);
context.createMarshaller().marshal(employee, writer);
writer.close();
}

}


Problem is i am using annotations to mark root element and other element and i am not supposed to use annotations.
I have to do it using schema (may be xsd file). Can any one guide me how to do this.



Hi Gaurav,

(I have to do it using schema (may be xsd file)) => You mean that, you want create java classes from xsd .
Correct me if i'm wrong
13 years ago

Rob Spoor wrote:

Darryl Burke wrote:And what exactly does this have to do with Swing / AWT / SWT / JFace? I think it would sit better in the Blatant Advertising section.
https://coderanch.com/forums/f-39/ba


Exactly.




Thanks.
13 years ago