I am a beginner in programming so please bear with my lack of knowledge.
I am working on sending and receiving a soap request via HttpsURLConnection. The problem is, the reply from the input stream has namespace declarations and the application does not recognize these.
I take the result from the input stream as text:
def reply = bufferedReader.getText()
but I can also create a Soap Message:
reply = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL).createMessage(null, conn.getInputStream())
Both methods still give namespace prefix. But I'm not sure if I've missed something. I can manipulate both XML and SoapMessage so any pointers will help.
When I send a request using SoapConnection.connect(), the XML file doesn't contain the prefix. However, when I use HttpsURLConnection, I get these. I cannot use SoapConnection.connect() for other reasons though.
I have been struggling for many hours. Any help is appreciated. Please ask if you need more info.
Thanks,
Related
In Java, I need to add a SOAP header containing authentication data for a client-side SOAP request to a 3rd party web service that I have no control over. I have set up a SOAPHandler, and am monitoring the actual code sent to the server-side to see what is going on. The authentication is not working.
What I precisely need is:
<soap12:Header>
<AuthenticationHeader xmlns="http://abc.xyz.com/">
<UserName>uname</UserName>
<Password>pwd</Password>
</AuthenticationHeader>
</soap12:Header>
I can create the AuthenticationHeader element and add it with the SOAPHeader.addHeaderElement method without issue, but I can't get the username and password content added properly. What I can get from using the various commands to set the text for a SOAPElement (setValue, setTextContent, addTextNode), and then using SOAPHeaderElement.addChildElement is
<soap12:Header>
<AuthenticationHeader xmlns="http://abc.xyz.com/">
<UserName xmlns="">uname</UserName>
<Password xmlns="">pwd</Password>
</AuthenticationHeader>
</soap12:Header>
The server side can't cope with the extra xmlns="" that all the commands I have tried seem to add to the UserName and Password tag names.
If I try to construct a string and add that text directly to the AutheticationHeader element, the < and > characters are escaped. I've also tried CDATA tags...that prevents escaping of the < and > characters, but the server still doesn't like it.
I found a solution constructing a Document to hold the raw text (which prevents escaping the characters), and then adding that, but unfortunately, it seems that Document can only be added to the SOAP body, not the SOAP header.
Does anyone have any suggestions how to overcome this? The server people are programming in .NET, not Java, so they aren't able to help.
I am getting the proper response back from the server, with all off the correct SOAP output tags, but the error message contained in the tag is "Can't Authenticate".
Thanks!
Following code will generate the correct Authentication Header that you would like to generate.
SOAPHeader header = request.getSOAPHeader();
Document doc = header.getOwnerDocument();
Element el1 = doc.createElementNS("http://abc.xyz.com/","UserName");
el1.setTextContent("MyName");
Element el2 = doc.createElementNS("http://abc.xyz.com/","Password");
el2.setTextContent("pass******");
Element el0 = doc.createElementNS("http://abc.xyz.com/", "AuthenticationHeader");
el0.appendChild(el1);
el0.appendChild(el2);
header.appendChild(el0);
I'm start learning java programming, and I want make a simple server application. I read about com.sun.net.httpserver.HttpServer and find a good example on this link: https://github.com/imetaxas/score-board-httpserver-corejava.
I understand how to do Get-request in url, but I don't know how POST works. I think it must be sent a form or data on the server.
I attach the link of project, which I'm learning, in readme the author wrote http://localhost:8081/2/score?sessionkey=UICSNDK - it's not working...
I wrote in url and get sessionkey: "localhost:8081/4711/login --> UICSNDK"
I wrote in url this for Post request: "localhost:8081/2/score?sessionkey=UICSNDK" - not working and in chrome return 404 bad request
3.wrote in url this:"localhost:8081/2/highscorelist"
Please help me, I am beginner.
The difference between GET and POST is that with a GET request the data you wish to pass to the endpoint is done by modifying the url itself by adding parameters to it.
With a POST any data you wish to send to the endpoint must be in the body of the request.
The body of a request is arbitrary data that comes after a blank line in the header The reqiest has the request line, following by any number of header attributes, then a blank line.
The server would need to know what the format of the body of the request was and parse it as appropriate.
Of course 'modern' frameworks like jax-rs allow you to automatically convert request data to objects, so that it is much simpler.
Hi are there any frameworks or libraries in php equivalent to jpos?
I came across JAK8583 php library which can parse and generate ISO 8583 messages.
However I want a php library which can generate ISO 8583 response message for ISO 8583 request message .
Please let me know if there are any.
Hi I don't know any alternative but you can always parse the request and set the response fields on that parsed request.
You can see implementation of ISOMsg.setRespnseMTI as inspiration.
Regards
You can check out this php library for iso8583.
Please note that in general you cannot throw a request at a library and tell it to give you a response that will be useful. You need to populate the response with data that is relevant to the transaction.
So normally you would get the request, create a response from the request, populate the response with relevant data, then send it.
I'm new to web-service integration as well as SOAP services. And, I was trying to integrate Sabre SOAP web services using java. On the SabreDevStudio website they provided the sample SOAP request which is format given below.
<RequestPayload>
<OTA_AirAvailRQ Version="2.2.0"
xmlns="http://webservices.sabre.com/sabreXML/2011/10"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<OriginDestinationInformation>
<FlightSegment DepartureDateTime="12-21">
<DestinationLocation LocationCode="DFW"/>
<OriginLocation LocationCode="HNL"/>
</FlightSegment>
</OriginDestinationInformation>
</OTA_AirAvailRQ>
</RequestPayload>
My Questions are
1, is is this all that is part of the request format?(I mean, did they hide the rest of the XML format purposefully because it was obvious?)
2, If it is so, what should it be..?
3,Somebody please explain the significance of all the three "xmlns" in the code? Which one is the request url and which one is the namespace...?
Thanks in advance.
PS:- It'll be a great help if you can create the equivalent java code for the above request. Please.
See, if you're using SOAP based service, this will be appended by it's header part as well. This node can be kept in body part but the header will have to be implemented with having binarytoken freshly created within 30 minutes (Default time to expire a token).
This explains your question 1 & 2, and for third question the answer is:-
if you'll go through the XSD's, you'll find the use of various xmlns. Better to use marshalling and unmarshalling to consume the services.
If this doesn't give a clear picture, I'll try to give you a sample of already created request.
I hope you're aware of the fact that the first service would be SessionCreateRQ.
I have built my Stub and other Web Service Facade classes via wscompile. The request can be built with no problems, but once it is sent off, the following error arises:
javax.xml.rpc.soap.SOAPFaultException: WSEC5061E: The SOAP Body is not signed.; null
at com.sun.xml.rpc.client.StreamingSender._raiseFault(StreamingSender.java:365)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:228)
The error clearly states that The SOAP Body is not signed. From my knowledge, this seems like I am doing something incorrect with setting the system properties. Below is what properties I have set:
System.setProperty("javax.net.debug","ssl");
System.setProperty("javax.net.ssl.keyStoreType","pkcs12");
System.setProperty("javax.net.ssl.keyStore",KeystorePath);
System.setProperty("javax.net.ssl.keyStorePassword",KeystorePassword);
System.setProperty("javax.net.ssl.trustStoreType","jks");
System.setProperty("javax.net.ssl.trustStore",TrustStorePath);
System.setProperty("javax.net.ssl.trustStorePassword",TrustStorePassword);
I have searched a bit about signing the body of a SOAP request with a public key or KeyStore but don't really know much about the topic, so I am probably searching for the wrong keywords.
If anyone could point me in the direction of any information or tutorials it would be greatly appreciated.
Thanks