I am sending the JSON object to server in a Java standalone application .
JSON object is :
{"dateFrom":"0001-01-01 12:00:00"
,"dateTo":"2014-03-29 04:34:49"
,"currency":"AUD"
,"requestStatus":null
,"dateTimeCreated":null
,"requestName":"ProjectedFundingRequest"
,"id":"af2e7ceb-c181-4a6b-a212-2867ea5cfded"
,"loginName":"mendiras"
,"securityToken":null
,"jsonString":null}
error : net.sf.json.JSONException: Error while setting property=requestStatus type class java.lang.String
Please let me know what could be the reason for the above error.
You are passing some null data in your JSON, Make sure server is accept this type of input otherwise at the time of server call it gives a error.
Set "requestStatus":null to "requestStatus":"",
Related
I have a problem when trying to retrieve data from Manage Price Quote Details (PriceQuoteServicesRQ) 4.10 Sabre SOAP API.
I generated Java classes using the WSDL from Sabre website (https://developer.sabre.com/docs/soap_apis/air/fulfill/manage_price_quote_details/resources).
I am constructing my request object in a following way:
ReservationTypeShort reservation = new ReservationTypeShort();
reservation.setValue("YEZUYS");
PriceQuoteInfoSearchParameters info = new PriceQuoteInfoSearchParameters();
info.setReservation(reservation);
PriceQuoteSearchParameters searchParameters = new PriceQuoteSearchParameters();
searchParameters.getPriceQuoteInfo().add(info);
searchParameters.setResultType(StringResultType.S);
GetPriceQuoteRQ req = new GetPriceQuoteRQ();
req.setSearchParameters(searchParameters);
req.setVersion("4.1.0");
I pretty-printed the object and this is what I got:
"priceQuoteInfo" : [ {
"reservation" : {
"value" : "YEZUYS",
"createDate" : null
},
"status" : [ ],
"type" : null,
"priceQuote" : [ ],
"travelItinerary" : null
} ],
So according to their documentation:
I am supplying all fields that are necessary, however it still doesn't work for me.
Did anybody else had the same problem? What am I missing/what am I doing wrong?
This is the error message I am getting:
XML request schema validation failed: PriceQuoteInfo element is not complete. One of the following fields: Status, Type, PriceQuote, TravelItinerary should be used. Please amend your request and try again.
What I have tried so far?
I asked Sabre Support for help, but they responded with a message that basically says "it works on my end".
I intercepted the XML body:
<ns5:GetPriceQuoteRQ version="4.1.0">
<ns5:SearchParameters resultType="S">
<ns5:PriceQuoteInfo>
<ns5:Reservation>YEZUYS</ns5:Reservation>
</ns5:PriceQuoteInfo>
</ns5:SearchParameters>
</ns5:GetPriceQuoteRQ>
I was missing an empty element <PriceQuote/> in my request.
It can be added by doing:
PriceQuoteInfoSearchParameters info = new PriceQuoteInfoSearchParameters();
info.setReservation(reservation);
info.getPriceQuote().add(new PriceQuoteSearch());
So according to their documentation I am supplying all fields that are necessary [...]
By documentation do you mean the WSDL or some human readable documentation (like PDF, DOCX, web pages, etc)? According to the error message you get, your SOAP request isn't valid. Sabre Support responding with "it works on my end" is another way of saying that you are not doing something correctly on your end. You need to troubleshoot your request.
From what I see, the error message is saying Status, Type, PriceQuote, and TravelItinerary but you are sending status, type, priceQuote, and travelItinerary. XML is case sensitive, and it's possible the service field names are too, so this might be the first thing to check.
Then, two of your fields (type and travelItinerary) are null. Also, priceQuote is empty. Is that OK? This is the next thing to check.
The object you pretty-printed shows a JSON format. Is this actually the format you are sending on the wire to the service? SOAP wants XML, not JSON. You also mention you generated the code from the WSDL. Using what framework or library? Does the generated code send XML?
Like I said, you need to troubleshoot the call:
download SoapUI
feed the WSDL file to SoapUI so that it can generate sample requests for you
fill in those request with real data and make calls to the web service until you get back a successful and expected response
using the same parameters from 3) in your code, perform the same call using your code
use SoapUI's monitoring tools to intercept the request at 4) and inspect the SOAP message you are sending
check the request you are making with your code against the successful request you got by using SoapUI directly
correct any differences until your request made by code is like the one send from SoapUI and it returns a successful and expected response.
I was meet a problem when I tried used net/jsonrpc package to build a server and a Java client with jsonrpc4j
The problem is jsonrpc4j is when error happen, golang`s method will return error and encoding to json.
I got this json object in client
{"id": -6028374044949000, "result": null, "error": "some error return message"}
This object cast failed in java's json4j.
http://www.jsonrpc.org/specification#error_object
After I checked the jsonrpc page, it is said the error field MUST a json object with fields [code, message, date], the golang jsonrpc package not meet the require.
So I`m confused how to solve this.
Change the jsonrpc lib,
Just replace the rpc way to thrift/gRpc,
Avoid to return error but send error in reply and let Java check the response,
Or just edited the json4j or golang's source code ( I'm very horrible about this option)
Thanks for watch.
If you need JSON-RPC 2.0 support for Go you can try https://github.com/powerman/rpc-codec
I have made import classes through WS Import and then place in eclipse . The problem is that I cannot process the message because of Unsupported media type . The problem is
'application/soap+xml; was not the expected type 'application/soap+msbin1'.
I know that we are requesting the service through Soap1.2 but service is asking from the WCF format but how can I solve this problem? Can anyone tell me how to change the application/soap+xml to application/soap+msbin1 through annotation not XML? I went through number of solution on web but couldn't get it to work, issues the problem is below?
The server sent HTTP status code 415: Cannot process the message
because the content type
'application/soap+xml;charset="utf-8";action="http://tempuri.org/IReceiveNoteService/ReceiveNote"'
was not the expected type 'application/soap+msbin1'.
Thanks #il_raffa for showing interest. Below is mine Sample client code
`/* Simply initializing the object for the service class*/
/* Create Resware Web Service Client... */
ReceiveNoteService receiveNoteService = new ReceiveNoteService();
/* Created Web Service by calling simple service*/
IReceiveNoteService port = receiveNoteService.getCustomBindingIReceiveNoteService();
/* Calling function and printing the response of service*/
/* Line where i am getting exception*/
System.out.println("Server response: " + port.receiveNote(newReceiveNoteData()));`
I cannot provide my WSDL File because of its privacy issue
I am using the GSON API 1.7.1 sometimes having following error. Is there a bug for this version? Do I need to upgrade the current version 2.x.x
com.google.gson.JsonParseException: Expecting object found: "<!DOCTYPE"
at com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler(JsonObjectDeserializationVisitor.java:100)
at com.google.gson.ReflectingFieldNavigator.visitFieldsReflectively(ReflectingFieldNavigator.java:63)
at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:120)
at com.google.gson.JsonDeserializationContextDefault.fromJsonPrimitive(JsonDeserializationContextDefault.java:85)
at com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializationContextDefault.java:56)
The server is google push notification server GCM,
Here is my client code.
Gson gson = new Gson();
com.sun.jersey.api.client.ClientResponse webResponse=
resource.header("Authorization", authorizationKey).
header("Content-Type", MediaType.APPLICATION_JSON).
post(com.sun.jersey.api.client.ClientResponse.class, payloadStr);
String responsePayload = webResponse.getEntity(String.class);
GcmResponse response = gson.fromJson(responsePayload, GcmResponse.class); ===>>> Exception point
Is there a bug for this version?
No. Looks like your server is returning a non-JSON response or you're passing wrong parameters, this has nothing to do with the version you're using.
Try to check if the server is working as expected and is returning a JSON.
<!DOCTYPE is not valid Json; your server sometimes sends the wrong messages to your client. Since your client works 99% of the time, the problem is clearly in the server somehow, not the client.
However, since you've only provided us information here from the client side, there isn't enough for us to fix the problem. The best thing to do would be to attempt to capture the complete error message, then use searches or post a different question "Why does my android-scm server send messages that begin with <!DOCTYPE when they should be Json?"
To capture this complete errant message, I would do:
if(response.startsWith("<!DOCTYPE")) {
someLoggingMethod(response);`
} else {
// process the response
I receive the following error when I'm trying to send a SOAP message.
The thing that has me confused, is that it seems like
Something fails in the C layer, the message "Object reference not set to an instance of an object." is a typical .net message if I recall.
It happens deep in the SOAP handler.
It happens when it receives the response.
It looks to me that it actually fails, trying to create an error message.
I'm using Glassfish 3.1.2.2, with its default SOAP framework (JAX-WS if I recall)
Any pointers on how to trace this error, and possibly get the actual received SOAP response, to see if it is the one to blame?
I have to add that I'm NOT a SOAP expert by any means of the definition. I just have to figure our why this fails. Unfortunately.
Stack trace:
com.sun.xml.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: Object reference not set to an instance of an object. Please see the server log to find more detail regarding exact cuase of the failure.
at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:193)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:134)
at com.sun.xml.ws.client.sei.StubHandler.readResponse(StubHandler.java:247)
at com.sun.xml.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:177)
at com.sun.xml.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:256)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:128)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:102)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:151)
This error is very hard to troubleshoot without any additional information like the SOAP request or the service WSDL.
Some things you can check in your code:
are your objects properly initialized?
do all attributes have the correct type?
check for null values