Twilio not communicating with my xml file stored on amazon S3 - java

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.

Related

what should we use SOAP and when should use REST?

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".

java httpServer Post request work

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.

Sabre Java SOAP api integration

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.

FEDEX API, Authentication Failed

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

Getting Permissions error while using stream.publish method of facebook API

Hi I want to publsh a post on user's wall but am getting this "permission error" error code 200 when trying to use stream.publish method of facebook api...i hve requested for extended permissions as:
http://m.facebook.com/login.php?api_key="+API_KEY&....&req_perms=read_stream,publish_stream,offline_access
but when i make call to the method stream.publish i am getting this permission error..it seems that req_perms in above url is simply getting ignored..
i am passing "method(stream.publish)","api_key","message","session_key","v","sig" as parametres to url http://api.facebook.com/restserver.php?
will be greatful if anyone helps meout in this problem or provide me with proper steps for publishing a post on user's wall...the application is being developed on blackbery platform..
I don't think you can request permissions from login.php. Instead check out prompt_permissions.php
http://wiki.developers.facebook.com/index.php/Authorization_and_Authentication_for_Desktop_Applications
Can you check to see if you are getting a valid session from facebook before trying stream.publish? If you are getting the offline_access extended permission, you will have a session object that has expires=0.
You can also try called the users.hasAppPermission API methods to verify you got the permissions.
Are you just making POSTs directly to http://api.facebook.com/restserver.php ? Are you including the request data in the POST body? You also should include a Content-Type: header of application/x-www-form-urlencoded in your headers.
I think it can be tricky to make direct calls to the restserver.php. Is there a client library you can use, like the Javascript client library?

Categories

Resources