I am integrating FEDEX Tracking, Rate and Shipping API's into my application but i am stuck with an issue.
When i run my code with Developer account details, everything runs correctly. But when i run the same code with production keys, it gives me "Error Code 1000, Authentication Error"
I have updated all keys and also changed the URL to point to production URL "https://ws.fedex.com:443/web-services/".
It doesn't seem to be a permission issue from FEDEX end as the standard services(Tracking) are enabled by default for production and that's also giving the same error "Error Code 1000, Authentication Error".
Below is the SOAP request and response XML.
REQUEST:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header/>
<soap:Body>
<RateRequest xmlns="http://fedex.com/ws/rate/v14">
<WebAuthenticationDetail>
<UserCredential>
<Key>AAAAAAAA</Key>
<Password>BBBBBBBBB</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>CCCCCCCC</AccountNumber>
<MeterNumber>DDDDDDDD</MeterNumber>
</ClientDetail>
<TransactionDetail>
<CustomerTransactionId>java sample - Rate Request</CustomerTransactionId>
</TransactionDetail>
<Version>
<ServiceId>crs</ServiceId>
<Major>14</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<ReturnTransitAndCommit>true</ReturnTransitAndCommit>
<RequestedShipment>
<ShipTimestamp>2015-04-19T18:21:11.542+05:30</ShipTimestamp>
<DropoffType>REGULAR_PICKUP</DropoffType>
<ServiceType>FEDEX_GROUND</ServiceType>
<PackagingType>YOUR_PACKAGING</PackagingType>
<TotalInsuredValue>
<Currency>USD</Currency>
</TotalInsuredValue>
<Shipper>
<Address>
<StreetLines>1310 Piper Dr</StreetLines>
<City>Milpitas</City>
<StateOrProvinceCode>CA</StateOrProvinceCode>
<PostalCode>95035</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</Shipper>
<Recipient>
<Address>
<StreetLines>3370 E. La Palma Avenue</StreetLines>
<City>Anaheim</City>
<StateOrProvinceCode>CA</StateOrProvinceCode>
<PostalCode>92806</PostalCode>
<CountryCode>US</CountryCode>
<Residential>false</Residential>
</Address>
</Recipient>
<ShippingChargesPayment>
<PaymentType>SENDER</PaymentType>
<Payor>
<ResponsibleParty>
<AccountNumber>ACCOUNT_NUMBER_PRESENT</AccountNumber>
</ResponsibleParty>
</Payor>
</ShippingChargesPayment>
<RateRequestTypes>ACCOUNT</RateRequestTypes>
<PackageCount>1</PackageCount>
<RequestedPackageLineItems>
<GroupPackageCount>1</GroupPackageCount>
<InsuredValue>
<Currency>USD</Currency>
<Amount>100.00</Amount>
</InsuredValue>
<Weight>
<Units>LB</Units>
<Value>10</Value>
</Weight>
<Dimensions>
<Length>1</Length>
<Width>1</Width>
<Height>1</Height>
<Units>IN</Units>
</Dimensions>
<SpecialServicesRequested/>
</RequestedPackageLineItems>
</RequestedShipment>
</RateRequest>
</soap:Body>
</soap:Envelope>
RESPONSE:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<v14:RateReply xmlns:v14="http://fedex.com/ws/rate/v14">
<v14:HighestSeverity>ERROR</v14:HighestSeverity>
<v14:Notifications>
<v14:Severity>ERROR</v14:Severity>
<v14:Source>prof</v14:Source>
<v14:Code>1000</v14:Code>
<v14:Message>Authentication Failed</v14:Message>
</v14:Notifications>
<v14:TransactionDetail>
<v14:CustomerTransactionId>java sample - Rate Request</v14:CustomerTransactionId>
</v14:TransactionDetail>
<v14:Version>
<v14:ServiceId>crs</v14:ServiceId>
<v14:Major>14</v14:Major>
<v14:Intermediate>0</v14:Intermediate>
<v14:Minor>0</v14:Minor>
</v14:Version>
</v14:RateReply>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Please help me resolve this issue :(
I faced this issue from last week and found solution finally after a discussion with FedEx Technical Person.See why we are facing such error all because of Developer Test Account we generated from developer website.One thing we should keep in mind that Test Account Number start with "6" is of Production & Key Start with "5" is Correct Test Key.So Please check your Test Key when you get Authentication problem with Error Code 1000.
Revert me if this is not helpful.
https://www.xadapter.com/test-use-fedex-account-number-test-account-number-password-use/
User Account Password is different from password we have to supply in web service.
please check above link
If you're getting the error for all web services in production then you've got a key issue. Get new credentials from the developer area of FedEx or try emailing websupport at fedex.com
I struggled and so I called their support in US, which I'll say is excellent. I had a chance to speak to some developer who will observe your requests in real time and will inform you over call like what's causing this authentication issue. Call here >> 1.877.339.2774
Now as per their support person, sometime while registering multiple times the earlier generated password gets overwritten with new, while key / account & meter numbers remain the same. (test & prod key passwords are sent over email you've registered with).
So if you're sure that you're using test/production credentials correctly mentioned in your code then you try re-registering for keys and must put your direct email address on the registration form. The new password will help you get a success response from APIs.
Also, if you're using api to track a shipment, then test creds will only help if you've supplied a test tracking number, same is for production keys. Prod keys will only work for real shipment tracking IDs
Related
When should we use SOAP and when should we use REST?
Can someone give a justifiable answer to this.
This was asked during an interview. I said it's up to contract with other parties. I don't know whether this is right or wrong. Can someone help with this.
SOAP I mean structure like below.
<?xml version='1.0' Encoding='UTF-8' ?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
<m:reservation xmlns:m="http://travelcompany.example.org/reservation"
env:role="http://www.w3.org/2003/05/soap-envelope/role/next">
<m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</m:reference>
<m:dateAndTime>2007-11-29T13:20:00.000-05:00</m:dateAndTime>
</m:reservation>
<n:passenger xmlns:n="http://mycompany.example.com/employees"
env:role="http://www.w3.org/2003/05/soap-envelope/role/next">
<n:name>Fred Bloggs</n:name>
</n:passenger>
</env:Header>
<env:Body>
<p:itinerary xmlns:p="http://travelcompany.example.org/reservation/travel">
<p:departure>
<p:departing>New York</p:departing>
<p:arriving>Los Angeles</p:arriving>
<p:departureDate>2007-12-14</p:departureDate>
<p:departureTime>late afternoon</p:departureTime>
<p:seatPreference>aisle</p:seatPreference>
</p:departure>
<p:return>
<p:departing>Los Angeles</p:departing>
<p:arriving>New York</p:arriving>
<p:departureDate>2007-12-20</p:departureDate>
<p:departureTime>mid-morning</p:departureTime>
<p:seatPreference></p:seatPreference>
</p:return>
</p:itinerary>
</env:Body>
</env:Envelope>
In very few words, using REST you can describe the same operations you may expect from a database find, insert, update, delete. In REST such operation are paired with the HTTP command: GET, PUT, POST, DELETE. That's also why REST is referred as "state transfer" in the sense that you move objects in/out like in a database, in other words changing the state of your "model".
On the other hand SOAP reflect more a Remote Call Procedure (RPC) where, the message is heavily structured by XML, this means that in SOAP you do not simple transfer data but submit commands. In SOAP you can define, like in a programming language, methods and parameters. Regarding this last point to allow a client to use the "methods" (really are well structured XML messages, with name and parameters) defined by a SOAP service, the same service has to publish an XML document describing what messages and their format it can accept: if the method does not exists, it throws an error like "Service not supported".
I am developing a jsf + spring application and in that trying to get all the emails send through the sendgrid api using the "/messages" endpoint .
I tried implementing the "/messages" endpoint in Java similar to the "/stats" endpoint mentioned in the example here. Below is my code
I am initializing the send grid object in my application context
<bean id="sendGrid" class="com.sendgrid.SendGrid">
<constructor-arg name="apiKey" value="my_api_key"/>
</bean>
Then I am using the autowired instance of that object in my service bean as follows:
com.sendgrid.Request request = new Request();
try {
request.setMethod(Method.GET);
request.setEndpoint("messages");
request.addQueryParam("limit", "10");
request.addQueryParam("query", "status='processed'");
com.sendgrid.Response response=sendGrid.api(request);
LOGGER.debug(response.getBody());
} catch (IOException e) {
LOGGER.error(ExceptionUtils.getStackTrace(e));
}
However I am receiving the following exception
Stack Trace:
java.io.IOException: Request returned status Code 400 Body:{"errors":[{"message":"authorization required"}]}
at com.sendgrid.Client.executeApiCall(Client.java:287)
at com.sendgrid.Client.get(Client.java:163)
at com.sendgrid.Client.api(Client.java:308)
at com.sendgrid.SendGrid.makeCall(SendGrid.java:203)
at com.sendgrid.SendGrid.api(SendGrid.java:225)
Since I am able to send e-mail and receive stats successfully. I don't think authorization should be the problem here. Am I going wrong somewhere or am I missing something?
Any guesses or leads welcome. Thanks
I contacted the sendgrid support team and It was an API Key issue. Since I was trying out the free account, I did not have access to that particular endpoint. However once I upgraded to a paid account with the email activity add on, It worked.
Yes, like Pranay said, You have to purchase Add-On named as "Extended Email Activity History" located at (once you logged in with send grid, look for) Settings → Account_Details → Product_Page → Scroll down to add-ons → then select "Extended Email Activity History" and add to your plan. (Current cost of this add-on is $12/month* & I don not understand meaning of * here)
You can check following link for sendgrid code snippet
https://docs.sendgrid.com/api-reference/e-mail-activity/filter-all-messages
Hope this helps
PK
I have a twilio account and am able to make calls. I am also able to use twiML Bins to do some text-to-voice. I however would like to call people hand play the recording stored on my amazon server, my java code is as follows:
callParams.put("To", "#number");
callParams.put("From", "#number");
callParams.put("Url", "https://myserveraddress/play.xml");
The xml code is as follows:
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Play>https://myserveraddress/jazz.mp3</Play>
</Response>
My mp3 is stored in the same location as my xml. But when I try make a call the twilio debugger tells me:
Error - 11200. HTTP retrieval failure.
Any Help will be appreciated.
Twilio evangelist here.
By default Twilio is going to make a POST request to the Url, and I'm guessing your web server can't serve a .xml from a POST request. You can send the Method param to tell Twilio to make a GET request instead:
callParams.put("To", "#number");
callParams.put("From", "#number");
callParams.put("Url", "https://myserveraddress/play.xml");
callParams.put("Method", "GET");
Here is a longer sample: http://twilio.com/docs/api/rest/making-calls#example-5
Hope that helps.
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'm developing a program that queries and prints out open data from the local transit authority, which is returned in the form of an XML response.
Normally, when there are buses scheduled to run in the next few hours (and in other typical situations), the XML response generated by the page is handled correctly by the java.net.URLConnection.getInputStream() function, and I am able to print the individual results afterwards.
The problem is when the buses are NOT running, or when some other problem with my queries develops after it is sent to the transit authority's web server. When the authority developed their service, they came up with their own unique error response codes, which are also sent as XMLs. For example, one of these error messages might look like this:
<Error xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Code>3005</Code>
<Message>Sorry, no stop estimates found for given values.</Message>
</Error>
(This code and similar is all that I receive from the transit authority in such situations.)
However, it appears that URLConnection.getInputStream() and some of its siblings are unable to interpret this custom code as a "valid" response that I can handle and print out as an error message. Instead, they give me a more generic HTTP/1.1 404 Not Found error. This problem cascades into my program which then prints out a java.io.FileNotFoundException error pointing to the offending input stream.
My question is therefore two-fold:
1. Is there a way to retrieve, parse, and print a custom XML-formatted error code sent by a web service using the plugins that are available in Java?
2. If the above is not possible, what other tools should I use or develop to handle such custom codes as described?
URLConnection isn't up to the job of REST, in my opinion, and if you're using getInputStream, I'm almost certain you're not handling character encoding correctly.
Check out Spring's RestTemplate - it's really easy to use (just as easy as URLConnection), powerful and flexible. You will need to change the ResponseErrorHandler, because the default one will throw an exception on 404, but it looks like you want it to carry on and parse the XML in the response.