I am a newbie. I need to invoke a servlet (located in a Application server) from webMethods. This servlet accepts 2 parameters and returns a xml based output which i need to map it webMethods document.
Can you pls help me how to do this. I would really appriciate if you can guide me step by step approach.
Usually, you can use pub.client:http to perform a post to the URL of the servlet. You can pass the two variables as parameters on the URL in the form ?variable1=value1&variable2=value2 or by mapping the two variables on the args parameter of the pub.client:http.
Other servlets require an XML document to be posted as the body of the post.
Please review the webMethods 6.x Built-In Services Guide for more information on the {pub.client:http} service.
The servlet will be expecting xml [approx 50 xml feilds] as the input from webMethods. The servlet will read this xml and return another xml as out put.
I did look into pub.client:http but could not figure out how to pass XML as input to the servlet
Can you pls let me know how to do this step by step
Basically you have to wrap up whole XML in a string or bytes (use stringTobytes service) and map the string in the client:http data/string or bytes,set headers/content-type=“text/xml”.This will post the xmldata to your target Servlet.And the servlet should handle this xmldata string at the receiving end.
I encountering some problems -Here is what i am doing
In the client.http I am passing - url value
- method Post
- loadAS bytes
- data/args/content= xml stirng
- data/args/soapAction = “some parameter”
- headers/content-type=text/xml
I am tring to connect to a webSphere application which hosts the service.
But when i run my service I am getting the follwing
lastError/pipeline/header/lines/Connection = Close
lastError/pipeline/header/status= 500
lastError/pipeline/header/statusMessage=InternalServerError
Check in google for InternalServerError,your service inputs looks good…
Also make sure your webSphere application is up and running and i believe you are sending the required params by the target application.
I am passing the same parameters as required by the service on websphere. when i invoke the service[websphere] using a HTML GUI i am getting the result back but when i invoking the service through client.http i am getting errors.
I wonder if webMethods adds on or wraps the http requests?
If thats the case there might be missing some info in http service or network transport layer from WM is not working as expected.Did you contacted your WM admin or sysadmin?
Inspite of setting Content-Type = text/html as a parameter in the header field - I am getting Content-type: application/x-www-form-urlencoded in the Network protocol level
I am getting Error 500: JAXM POST failed Unable to internalize message
This is because of the reason indicates that the content-type that is
being used is application/x-www-form-urlencoded. According to the SOAP
1.1 specification Section 6 the content-type for any content needs to be text/xml
How can i change the content type to text/xml from application/x-www-form-urlencoded - which is defalut in client.http.
I have added a variable Content-type=text/xml in header.But at the runtime the content-type = application/x-www-form-urlencoded.
Any help on converting application/x-www-form-urlencoded to text/xml will be appricitate.
If you are sending a soap message to your servlet, you will probably want to use pub.client:soapHTTP or pub.client:soapRPC to send the message instead of pub.client:http.
Is your servlet expecting a simple XML document or is it expecting a soap message?
The servelt is expecting a simple xml and returning a SOAP message.
I figured it out how to set the content-type= text/xml.
If one passes any information in the arguments webMethods by defaults the content-type to application/www.url…
But I have 2 variables which needs to be passed to the servlet and also set the content type =text/xml.
Currently i am passing one of the two variable in the string feild of client.http service, by doing so i can overwrite content type to text/xml. Is there a way by which i can pass pass 2 name value pairs to the service without using args feild
What kind of convoluted servlet accepts plain ole XML but returns a soap message? I’ve never heard of that before. I guess asking for a WSDL that describes this service is out of the question, right?
So you need to send an xml file in the body of the post as well as two non-xml arguments? I don’t think a content-type of text/xml is correct for that arrangement since only one of the parms is XML.
This is a way weird implementation. I’m not sure how to advise you on this.
IMHO, if the servlet will return a soap message, it should accept one. If it is pretending to be a web service it should have a WSDL that describes it. If the service will accept XML doc only then you can use text/xml as the content-type. If the service needs to accept xml plus other args, text/xml is not correct.
If you are describing this correctly, it may be so screwed up that you’ll have to write a custom java service to do the post and force the content-type. Perhaps you could clarify with the developer / owner of the servlet, just how they intend for others to use their amazing service.