I'm working with a WSDL that has a different SOAP Action in the header to the one I would expect. At the moment when I call the web service, I just get like a .NET description site of a web service. In this instance it's
https://preprod.squidcard.com/ytm/sQuidpages/sQuidPWS.asmx
What URL should I actually call to get to the getPurseBalance() method as the option in the SOAP Action from the WSDL doesn't seem to be defined, is there anyway I can determine this or should I go to the web service provider?
Thanks,
You should not call a URL, you should post a XML to this direct same page. To know what to send to the web service you can check your URL:
https://preprod.squidcard.com/ytm/sQuidpages/sQuidPWS.asmx?op=getPurseBalance
Here you can also view your SoapAction and other headers to be send:
POST /ytm/sQuidpages/sQuidPWS.asmx HTTP/1.1
Host: preprod.squidcard.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://secure.squidcard.com/getPurseBalance"
If you don't want to create XML manually you can also use the SoapClient class from PHP. You can find more information here:
http://www.php.net/manual/en/class.soapclient.php
$client = new SoapClient("https://preprod.squidcard.com/ytm/sQuidpages/sQuidPWS.asmx?WSDL");
var_dump($client->__getFunctions());
$client->__soapCall("getPurseBalance", array('your parameters'));
see this http://www.php.net/manual/en/soapclient.setlocation.php
I think you should use
$client->__setLocation('https://preprod.squidcard.com/ytm/sQuidpages/sQuidPWS.asmx');
Related
Hi I am trying to push the notification from rest client to android app. I am doing like below -
URL - https://android.googleapis.com/gcm/send
Method - POST
Headers - Authorization: my_server_key
I always get this message
Status Code: 401 Unauthorized
Alternate-Protocol: 443:quic,p=0.002
Cache-Control: private, max-age=0
I am not sure what I am missing & last I am using correct server api key.
Please assist & thanks in advance.
Push notification uses Web Socket. You cannot do this using HTTP protocol unless you have a server side implementation set up to respond to your request through Web Socket.
I set this values in the header then it is working fine for me.
Below is the header key & value.
A) Authorization: & it value likes key=API_KEY
B) Content-Type: application/json
I hope you are done with your request but it will help to others
You have to send like this
In head
-------
Headder Value
Authorization key=your value
Content-Type application/json
In Body
-------
Something like this
{
"registration_ids" : ["Your id"],
"data" : {
"message":"Your message"
}
}
Hope it will help
I'm a building a RESTful API using Zend Framework 2 and Apigility by Zend Framework.
For testing, I use the chrome extension Postman REST-Client.
I can do GET requests and POST requests without problems by sending form-data without problems.
But when I try to do a PUT, PATCH or DELETE request, I get the following error:
{
"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title":"Unsupported Media Type",
"status":415,
"detail":"Invalid content-type specified"
}
Accept whitelist in Rest-Service-Config of Apigility:
application/vnd.timber-ms.v1+json, application/hal+json, application/json
Content-Type whitelist:
application/vnd.timber-ms.v1+json, application/json
The content-type of the response is application/problem+json
What can I do to fix this and do successfull PUT/PATCH requests?
Is this a problem with Postman or Apigility?
You're getting the 415 error of Unsupported Media Type when Apigility cannot deserialize the data coming from the client. This recently was called out in the documentation.
I suspect your problem is due to the content-type being sent from postman. Pay special attention to the Content-Type Whitelist listed for the service and make sure it contains the content-type you are sending.
For example, if your service has only has application/json in the Content-Type Whitelist and you send the PUT/PATCH with postman as x-www-form-urlencoded, you will get a 415 error of Unsupported Media Type. If you change postman to send the PUT/PATCH with a content-type of application/json and the request body contains valid JSON, Apigility should accept the request.
You can check the content-type postman is sending by clicking on the "Preview" button just to the right of the "Send" button.
I was having a similar issue in Postman with the unsupported media type responses. However, I experienced this response on both PUT and POST requests using my company's API.
I verified that Postman was the problem here and not the request/API in use by running the same request with another similar Chrome extension called Advanced REST Client. I'm not familiar with Apigility, but pretty sure that Postman is the culprit here.
Hoping there is a fix for this issue as Postman and its collections feature is much easier to use than that of Advanced REST Client.
on postman go to normal tab (or other auths tab) and add header:
Content-Type application/json (or any type you need)
make sure that on the raw tab include the json data
{
"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title":"Unsupported Media Type",
"status":415,
"detail":"Invalid content-type specified"
}
I had the same problem,
My solution was to write my data to [Body] in the [raw] in json format. Like this:
{"message": "UPDATED First Post!"}
And in [Headers] :
[KEY] Content-Type
[Value] application/json
I need to make call to SOAP 1.1 web service in PHP. However, one of requirements in order to work is that I must send Content-Type=application/soap+xml. Now, I know that these are differences:
SOAP 1.2 -> Content-Type: application/soap+xml
SOAP 1.1 -> Content-Type: text/xml
I need to use SoapClient with WSDL to do this. However, I couldn't find how to set Content-Type after I set version to SoapClient to 1.1
Could someone provide example or code snippet?
Thank you!
There are a number of headers that are ignored when you try to set them in a stream_context, and will never be used.
Check the underlying C source file soap/php_http.c and search for "skip some predefined headers" for a list.
This is the reason some people report problems trying to set Host, Authorization, Content-Type and other headers in certain situations.
You can supply a stream context in the SoapClient options.
$ctx_opts = array(
'http' => array(
'header' => 'Content-Type: application/soap+xml'
)
);
$ctx = stream_context_create($ctx_opts);
$soapClient = new SoapClient('your.wsdl', array('stream_context' => $ctx));
I am developing an UI for a REST repository using PHP and the PEAR HTTP REQUEST package (http://pear.php.net/package/HTTP_Request/).
I created a HTTP GET request and it delivers the requested rdf/xml file as expected. But I want to extend this request and I can't get this working.
The repository allows sending zip files which are attached to an id. So I have to call the same URL which delivers the rdf/xml data, but I have to change the HTTP GET header from xml to accept: application/zip, before executing my request. This should deliver the zip instead of the rdf/xml file.
$req =& new HTTP_Request();
$req->setMethod(HTTP_REQUEST_METHOD_GET);
$req->setURL($url);
$req->clearPostData();
if (!PEAR::isError($req->sendRequest())) {
$response2 = $req->getResponseBody();
} else {
$response2 = "";
}
echo $response2;
Does anyone know how to modify the GET call to get this done? I really need help!
Furthermore I want to create a HTTP PUT request which uses multipart/form-data. Does anyone know how to make this?
Please help me! Thanks!
For your first question, you can set the Accept field of your GET request header by:
$req->addHeader('Accept', 'application/zip');
# assuming that this will trigger the server to respond with the zip and not xml
Question number 2:
# Set method to PUT
$req->setMethod(HTTP_REQUEST_METHOD_PUT);
# Attach file to request
$req->addFile('file_upload_field', '/path/to/file.ext', 'application/zip');
Read up more on file uploads using HTTP_Request.
To modify the request headers, take a look at the addHeader() method of the HTTP_Request object: http://pear.php.net/manual/en/package.http.http-request.headers.php
To change the method, use the setMethod(): http://pear.php.net/package/HTTP_Request/docs/latest/HTTP_Request/HTTP_Request.html#methodsetMethod
I have successfully gotten an access_token, so it's not a problem with the 3-legged process.
The problem starts when I try to add a new post/activity using the Buzz API...
Here is my request:
POST /buzz/v1/activities/#me/#self?alt=json HTTP/1.1
Host: www.googleapis.com
Connection: close
Accept-encoding: gzip, deflate
User-Agent: Zend_Http_Client
Content-Type: application/json
Authorization: OAuth
realm="",oauth_consumer_key="example.com",oauth_nonce="ce29b04ce6648fbb92efc8f 08c1c0091",oauth_signature_method="HMAC-
SHA1",oauth_timestamp="1277934794",oauth_version="1.0",oauth_token="1%2FcBz o5ckGvCAm3wLWh1SDH3xQNoW--
yek1NVfUa1Qqns",oauth_signature="CUezSiMbvxyN1BTeb3uROlIx8gA%3D"
Content-Length: 86
{"data":{"object":{"type":"note","content":"posting on Buzz"}}}
Here is the response:
{"error":{"errors":[{"message":"Unknown authorization header","locationType":"header","location":"Authorization"}],"code":401,"message":"Unknown authorization header"}}
And here is my base string (the string that the signature gets generated from):
POST&https%3A%2F%2Fwww.googleapis.com%2Fbuzz%2Fv1%2Factivities%2F%40me
%2F%40self&oauth_consumer_key%3Dexample.com%26oauth_nonce
%3D50acc6b7ac48304ae9301134d6988cdb%26oauth_signature_method%3DHMAC-
SHA1%26oauth_timestamp%3D1278065599%26oauth_token
%3D1%252FcBzo5ckGvCAm3wLWh1SDH3xQNoW--yek1NVfUa1Qqns%26oauth_version
%3D1.0
I've even tried this other base string (with the alt=json added in):
POST&https%3A%2F%2Fwww.googleapis.com%2Fbuzz%2Fv1%2Factivities%2F%40me
%2F%40self%3Falt%3Djson&oauth_consumer_key%3Dexample.com%26oauth_nonce
%3Dee8704244623bbcc860bf77bfcadeacc%26oauth_signature_method%3DHMAC-
SHA1%26oauth_timestamp%3D1278069221%26oauth_token
%3D1%252FcBzo5ckGvCAm3wLWh1SDH3xQNoW--yek1NVfUa1Qqns%26oauth_version
%3D1.0
I have tried pretty much everything to get this working - not sure why it always says 'Unknown authorization header'... the header looks fine when compared to other ones that work.
Any ideas?
which endpoint did you use to authorize request token?
developer's guide:
Important: Part of the OAuth process
requires that you direct the user to
the Google Authorization service to
approve access for your application.
Google Buzz requires that you use a
different Authorization service
endpoint, located at
https://www.google.com/buzz/api/auth/OAuthAuthorizeToken.com/buzz/api/auth/OAuthAuthorizeToken.
You should use GET or POST method (depending what request you use). By default Zend uses header-method.
$client->setMethod(Zend_Http_Client::GET);