Is there any way I can set Content-length in the header when sending request with SoapClient?
I guess it should be possible to do that in SoapHeader function. But it is not clear to me how to input content-length in there. There is just mentioned setting of namespace in the documentation. But I dont need to change namespace or anything like that (it is already set in the wsdl file)..
Thanks for any useful answer.
Related
could anyone tell me how to add request headers for subscription keys in SOAP request.
I am using NuSOAP toolkit for making SOAP calls. Setting keys for authorisation SOAP calls seems difficult for me. Unless I pass the subscription keys in request headers, I didn't get an access.
I tried:
$this->nusoap_client->setHeaders("<soapHeader xmlns='http://test.com/'>
<Ocp-Apim-Subscription-Key>***mykey***</Ocp-Apim-Subscription-Key>
</soapHeader>");
but it adding keys to the soap header instead of request header.
Then I tried :
header("Ocp-Apim-Subscription-Key: ***mykey***");
but still no hope, its added to the response header now.
I am using $this->nusoap_client->call() for making SOAP call, and the response getting is
{ "statusCode": 401, "message": "Access denied due to missing subscription key. Make sure to include subscription key when making requests to an API." }
thanks in advance.
Well, I found a solution myself. Don't know if it is the right way or not! Anyway I would like to post my solution here, it may find useful to someone.
I solved this issue by modifying the nusoap library class file. Modified function soap_transport_http to set headers as:
$this->setHeader('Ocp-Apim-Subscription-Key', '***myKey***');
May be it is not the right way to modify headers in SOAP request, but it works for me. Please put your answer if you find better solution.
Questions
What is the difference between Header always set and Header set in Apache?
That is, what does the always keyword change about the circumstances under which the header is set?
Should I always set my headers using always?
Is there any reason not to?
Background
I've seen...
Header always set X-Frame-Options DENY
...as well as...
Header always set Access-Control-Allow-Headers "*"
...and I sometimes hear that the presence of the always keyword ensures that the header is properly set, or that it's simply better to include the always keyword in general. However, I have never found a clear, definitive answer for why that is the case.
I've already checked the Apache docs for mod_headers, which only briefly mention always:
When your action is a function of an existing header, you may need to specify a condition of always, depending on which internal table the original header was set in. The table that corresponds to always is used for locally generated error responses as well as successful responses. Note also that repeating this directive with both conditions makes sense in some scenarios because always is not a superset of onsuccess with respect to existing headers:
You're adding a header to a locally generated non-success (non-2xx) response, such as a redirect, in which case only the table corresponding to always is used in the ultimate response.
You're modifying or removing a header generated by a CGI script, in which case the CGI scripts are in the table corresponding to always and not in the default table.
You're modifying or removing a header generated by some piece of the server but that header is not being found by the default onsuccess condition.
As far as I can tell, this means that Header set always ensures that the header is set even on non-200 pages. However, my HTTP headers set with Header set have always seemed to apply just fine on my 404 pages and such. Am I misunderstanding something here?
FWIW, I've found SO posts like What is the difference between "always" and "onsuccess" in Apache's Header config?, but the only answer there didn't really explain it clearly for me.
Thanks very much,
Caleb
What is the difference between Header always set and Header set in Apache?
As the quoted bit from the manual says, without 'always' your additions will only go out on succesful responses.
But this also includes "successfully" forward errors via mod_proxy and perhaps other similar handlers that roughly act like proxies. What generates your 404s that you found to disagree with the manual? A 404 on a local file certainly behaves as the quoted bit describes.
That is, what does the always keyword change about the circumstances under which the header is set?
Apache's API keeps two lists associated with each request, headers and err_headers. The former is not used if the server encounters an error processing the request the latter is.
Should I always set my headers using always?
It depends on their significance. Let's say you were setting Cache-Control headers that were related to what you had expected to serve for some resource. Now let's say you were actually serving something like a 400 or 502. You might not want that cached!
Is there any reason not to?
See above.
-/-
There is also a bit in the manual you did not quote which explains the proxy or CGI of an error code but not for one which Apache is generating an error response for:
The optional condition argument determines which internal table of
responses headers this directive will operate against. Despite the
name, the default value of onsuccess does not limit an action to
responses with a 2xx status code.
Headers set under this condition are still used when, for example, a
request is successfully proxied or generated by CGI, even when they
have generated a failing status code.
I try to get some info from other sites with xbuf_frurl.
I got some site OK but some Not OK.
By Now, I still can not make sure what is going wrong.
But some sites are missing the content length header.
Who can tell whether xbuf_frurl() relies on the (potentially missing) content length header, esp. when growing the buffer?
xbuf_frurl() is indeed reading a body IF an HTTP content-length header is present. It will not try to decode chunked responses.
To deal with those servers using chunked replies, use the G-WAN curl.c example provided with the distribution. With libcurl you have even the opportunity to use SSL/TLS.
If that's not resolving your problem, the only way to troubleshoot this kind of issues is to give a non-working example, with both the full request that you have sent and the full reply received from the server.
That's why the xbuf_xcat("%v") format has been added: to give hexdumps, even with binary replies.
Edit your question and add this information to let people help you with a well-defined problem.
Using HttpWebRequest/Response, and the Trailer headers in the chunked-encoded response are being thrown away (I've actually stepped through the .Net 4.0 reference source to see where it calls RemoveTrailers after the final chunk). Is there any way to retrieve those headers? Also, does anyone know why this behavior is in place to begin with?
In case anyone asks, no, I can't ensure that the trailer headers are moved to the rest of the headers. This is simply the data stream format I have to work with.
I dont think there is any way to do that. As to why it is like this, when this feature was first being implemented, there was no known HTTP server that sent headers in chunked response trailers.
What kind of server is this? Is this a custom server that is doing this?
If you absolutely care about this, you can find a feature request at the MS connect website (http://connect.microsoft.com).
How do I read the Response Headers that are being sent down in a page ? I want to be able to read the header values and modify some of them. This is for an ASP.NET 1.1 application but I would be curious to know if it can done in any version of ASP.NET.
The reason for doing this is someone may have added custom headers of their own before the point I am examining the response - so I cannot blindly clear all the headers and append my own - I need to read the all the headers so I can modify the appropriate ones only.
HttpContext.Current.Response (Its a HTTPResponse), exposed ClearHeaders(), AddHeaders() and AppendHeaders().
Not as direct as it is now in later version of ASP.NET, but should be enough to let you modify the headers you wanted to modify.
http://msdn.microsoft.com/en-us/library/system.web.httpresponse_members(VS.71).aspx
AFAIK it cannot be done in ASP.NET 1.1. There is no way for you to get at the response headers - request headers are available but not response headers.
I am not sure if you can do this in other stacks like Java, LAMP though and I am curious to find out...