Jump to content

The url is stripped when sent.


ohrstedtl

Recommended Posts

Hello, I want to get data from a webservices by using file_get_contents, but I have a problem since the url is not sent as I have written it. The following code is used:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" lang="sv" xml:lang="sv">

<head>

<title></title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<meta name="description" content="" />

<meta name="keywords" content="" />

<meta name="author" content="Lennart Öhrstedt" />

<meta name="Copyright" content="Diadoker" />

<meta name="Company" content="Diadoker" />

<meta http-equiv="Language" content="Sv" />

<meta name="Robots" content="index,follow" />

<meta lang="Sv" />

<link rel="canonical" href="http://www.diadoker.se" />

</head>

<body>

<?php

$url = 'http://swea.riksbank.se:80/sweaWS/services/SweaWebServiceHttpSoap12Endpoint';

$request = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://swea.riksbank.se/xsd">'

.'<soap:Header/>'

.'<soap:Body>'

.'<xsd:getLatestInterestAndExchangeRates>'

.'<languageid>sv</languageid>'

.'<seriesid>SEKATSPMI</seriesid> <!--Österrike, shilling-->'

.'<seriesid>SEKAUDPMI</seriesid> <!--Australien, dollar -->'

.'<seriesid>SEKBEFPMI</seriesid> <!--Belgien, franc -->'

.'<seriesid>SEKBRLPMI</seriesid> <!--Brasilien, real -->'

.'<seriesid>SEKCADPMI</seriesid> <!--Canada, dollar -->'

.'<seriesid>SEKCHFPMI</seriesid> <!--Schweiz, franc -->'

.'<seriesid>SEKCNYPMI</seriesid> <!--Kina, yuan renminbi -->'

.'<seriesid>SEKCYPPMI</seriesid> <!--Cypern, pund -->'

.'<seriesid>SEKCZKPMI</seriesid> <!--Tjeckien, kronor -->'

.'<seriesid>SEKDEMPMI</seriesid> <!--Tyskland, mark -->'

.'<seriesid>SEKDKKPMI</seriesid> <!--Danmark, kronor -->'

.'<seriesid>SEKEEKPMI</seriesid> <!--Estland, kronor -->'

.'<seriesid>SEKESPPMI</seriesid> <!--Spanien, pesetas -->'

.'<seriesid>SEKEURPMI</seriesid> <!--Euroland, euro -->'

.'<seriesid>SEKFIMPMI</seriesid> <!--Finland, mark -->'

.'<seriesid>SEKFRFPMI</seriesid> <!--Frankrike, franc -->'

.'<seriesid>SEKGBPPMI</seriesid> <!--Storbritannien, pund -->'

.'<seriesid>SEKGRDPMI</seriesid> <!--Grekland, drachmer -->'

.'<seriesid>SEKHKDPMI</seriesid> <!--Hong Kong, dollar -->'

.'<seriesid>SEKHUFPMI</seriesid> <!--Ungern, forint -->'

.'<seriesid>SEKIDRPMI</seriesid> <!--Indonesien, rupee -->'

.'<seriesid>SEKIEPPMI</seriesid> <!--Irland, pund -->'

.'<seriesid>SEKINRPMI</seriesid> <!--Indien, rupee -->'

.'<seriesid>SEKISKPMI</seriesid> <!--Island, kronor -->'

.'<seriesid>SEKITLPMI</seriesid> <!--Italien, lire -->'

.'<seriesid>SEKJPYPMI</seriesid> <!--Japan, yen -->'

.'<seriesid>SEKKRWPMI</seriesid> <!--Syd Korea, won -->'

.'<seriesid>SEKKWDPMI</seriesid> <!--Kuwait, dinar -->'

.'<seriesid>SEKLTLPMI</seriesid> <!--Litauen, litas -->'

.'<seriesid>SEKLVLPMI</seriesid> <!--Lettland, lav -->'

.'<seriesid>SEKMADPMI</seriesid> <!--Marocko, dirham -->'

.'<seriesid>SEKMXNPMI</seriesid> <!--Mexiko, nuevo peso -->'

.'<seriesid>SEKMYRPMI</seriesid> <!--Malaysia, ringitt -->'

.'<seriesid>SEKNLGPMI</seriesid> <!--Nederländerna, gulden -->'

.'<seriesid>SEKNOKPMI</seriesid> <!--Norge, kronor -->'

.'<seriesid>SEKNZDPMI</seriesid> <!--Nya Zeeland, dollar -->'

.'<seriesid>SEKPLNPMI</seriesid> <!--Polen, zloty -->'

.'<seriesid>SEKPTEPMI</seriesid> <!--Portugal, escudo -->'

.'<seriesid>SEKRUBPMI</seriesid> <!--Ryssland, rubel -->'

.'<seriesid>SEKSARPMI</seriesid> <!--Saudiarabien, riyal -->'

.'<seriesid>SEKSGDPMI</seriesid> <!--Singapore, dollar -->'

.'<seriesid>SEKSITPMI</seriesid> <!--Slovenien, tolar -->'

.'<seriesid>SEKSKKPMI</seriesid> <!--Slovakien, koruna -->'

.'<seriesid>SEKTHBPMI</seriesid> <!--Thailand, baht -->'

.'<seriesid>SEKTRLPMI</seriesid> <!--Turkiet, lira -->'

.'<seriesid>SEKTRYPMI</seriesid> <!--Turkiet, ny lira -->'

.'<seriesid>SEKUSDPMI</seriesid> <!--Förenta Staterna, dollar -->'

.'<seriesid>SEKZARPMI</seriesid> <!--Sydafrika, rand -->'

.'</xsd:getLatestInterestAndExchangeRates>'

.'</soap:Body>'

.'</soap:Envelope>';

function alerten($texten)

{ echo "<script type='text/javascript' language='JavaScript'>alert('$texten');</script>";

}

function do_post_request( $url, $query_string )

{ $params = array('http'=> array('method'=>'POST','header'=>"Accept-Encoding:gzip,deflate"."r"."Content-Type:application/soap+xml;charset=UTF-8;action='urn:getLatestInterestAndExchangeRates'"."r".'Content-Length:'.strlen($query_string)."r"."Host:swea.riksbank.se:80"."r". "Connection:Keep-Alive"."r"."User-Agent:Apache-HttpClient/4.1.1 (java 1.5)"."rn", 'content' => $query_string) );

$context = stream_context_create( $params );

$contents = file_get_contents( $url, FALSE, $context );//alerten($contents);

return $contents;

}

$response = do_post_request($url, $request); //alerten($response);

?>

<div id="fot">

<table id="fotTabell" width="100%" summary="Copyright">

<tr>

<td align="center">

<span>

Copyright © <span id="år"> 2014 </span> Diadoker. All rights reserved.

</span><br />

<a href="mailto:lennart.ohrstedt@diadoker.se" style="color: black">

lennart.ohrstedt@diadoker.se

</a><br />

<a href="http://www.diadoker.se/" style="color: black">

www.diadoker.se

</a> <br />

</td>

</tr>

</table>

</div>

</body>

</html>

When I use WireShark to look at what is sent I found this for the first block:

POST /sweaWS/services/SweaWebServiceHttpSoap12Endpoint HTTP/1.0

Accept-Encoding:gzip,deflate
Content-type:application/soap+xml;charset=UTF-8;action='urn:getLatestInterestAndExchangeRates'
Content-Length:2881
Host:swea.riksbank.se:80
Connection:Keep-Alive
User-Agent:Apache-HttpClient/4.1.1 (java 1.5)
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://swea.riksbank.se/xsd"><soap:Header/><soap:Body><xsd:getLatestInterestAndExchangeRates><languageid>sv</languageid><seriesid>SEKATSPMI</seriesid> <!--Österrike, shilling--><seriesid>SEKAUDPMI</seriesid> <!--Australien, dollar --><seriesid>SEKBEFPMI</seriesid> <!--Belgien, franc --><seriesid>SEKBRLPMI</seriesid> <!--Brasilien, real --><seriesid>SEKCADPMI</seriesid> <!--Canada, dollar --><seriesid>SEKCHFPMI</seriesid> <!--Schweiz, franc --><seriesid>SEKCNYPMI</seriesid> <!--Kina, yuan renminbi --><seriesid>SEKCYPPMI</seriesid> <!--Cypern, pund --><seriesid>SEKCZKPMI</seriesid> <!--Tjeckien, kronor --><seriesid>SEKDEMPMI</seriesid> <!--Tyskland, mark --><seriesid>SEKDKKPMI</seriesid> <!--Danmark, kronor --><seriesid>SEKEEKPMI</seriesid> <!--Estland, kronor --><seriesid>SEKESPPMI</seriesid> <!--Spanien, pesetas --><seriesid>SEKEURPMI</seriesid> <!--Euroland, euro --><seriesid>SEKFIMPMI</seriesid> <!--Finland, mark --><seriesid>SEKFRFPMI</seriesid> <!--Frankrike, franc --><seriesid>SEKGBPPMI</seriesid> <!--Storbritannien, pund --><seriesid>SEKGRDPM
After POST I expected to see my full url as in $url. So I wonder if I have missed something in my code, or I need to use some other procedure. I send the file as well, named soap1.php.

soap1.php

Link to comment
Share on other sites

Your URL is fine. The POST part only is meant to show the path to the file. The content doesn't require the domain because the receiver of this message already knows who it is.

 

What response are you getting?

Link to comment
Share on other sites

Hello again

 

Here is the response taken from wireshark:

Hypertext Transfer Protocol
HTTP/1.1 500 Internal Server Errorrn
[Expert Info (Chat/Sequence): HTTP/1.1 500 Internal Server Errorrn]
[Message: HTTP/1.1 500 Internal Server Errorrn]
[severity level: Chat]
[Group: Sequence]
Request Version: HTTP/1.1
Status Code: 500
Response Phrase: Internal Server Error
Date: Wed, 19 Mar 2014 10:11:50 GMTrn
Server: Apachern
Content-Length: 528rn
[Content length: 528]
Connection: closern
Content-Type: text/html; charset=iso-8859-1rn
rn
[HTTP response 1/1]
[Time since request: 0.051121000 seconds]
[Request in frame: 10]
Line-based text data: text/html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">n
<html><head>n
<title>500 Internal Server Error</title>n
</head><body>n
<h1>Internal Server Error</h1>n
<p>The server encountered an internal error orn
misconfiguration and was unable to completen
your request.</p>n
<p>Please contact the server administrator at n
you@example.com to inform them of the time this error occurred,n
and the actions you performed just before this error.</p>n
<p>More information about this error may be availablen
in the server error log.</p>n
</body></html>n
0000 c8 bc c8 be e9 ea 08 60 6e 21 b7 28 08 00 45 00 .......`n!.(..E.
0010 02 f4 40 80 40 00 31 06 53 0e c2 0e cd 24 c0 a8 ..@.@.1.S....$..
0020 63 9a 00 50 d0 d4 08 9c 38 a6 de c4 02 f8 80 18 c..P....8.......
0030 fb b4 cd 4b 00 00 01 01 08 0a 43 67 df 3c 01 69 ...K......Cg.<.i
0040 ff a9 48 54 54 50 2f 31 2e 31 20 35 30 30 20 49 ..HTTP/1.1 500 I
0050 6e 74 65 72 6e 61 6c 20 53 65 72 76 65 72 20 45 nternal Server E
0060 72 72 6f 72 0d 0a 44 61 74 65 3a 20 57 65 64 2c rror..Date: Wed,
0070 20 31 39 20 4d 61 72 20 32 30 31 34 20 31 30 3a 19 Mar 2014 10:
0080 31 31 3a 35 30 20 47 4d 54 0d 0a 53 65 72 76 65 11:50 GMT..Serve
0090 72 3a 20 41 70 61 63 68 65 0d 0a 43 6f 6e 74 65 r: Apache..Conte
00a0 6e 74 2d 4c 65 6e 67 74 68 3a 20 35 32 38 0d 0a nt-Length: 528..
00b0 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 63 6c 6f 73 Connection: clos
00c0 65 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a e..Content-Type:
00d0 20 74 65 78 74 2f 68 74 6d 6c 3b 20 63 68 61 72 text/html; char
00e0 73 65 74 3d 69 73 6f 2d 38 38 35 39 2d 31 0d 0a set=iso-8859-1..
00f0 0d 0a 3c 21 44 4f 43 54 59 50 45 20 48 54 4d 4c ..<!DOCTYPE HTML
0100 20 50 55 42 4c 49 43 20 22 2d 2f 2f 49 45 54 46 PUBLIC "-//IETF
0110 2f 2f 44 54 44 20 48 54 4d 4c 20 32 2e 30 2f 2f //DTD HTML 2.0//
0120 45 4e 22 3e 0a 3c 68 74 6d 6c 3e 3c 68 65 61 64 EN">.<html><head
0130 3e 0a 3c 74 69 74 6c 65 3e 35 30 30 20 49 6e 74 >.<title>500 Int
0140 65 72 6e 61 6c 20 53 65 72 76 65 72 20 45 72 72 ernal Server Err
0150 6f 72 3c 2f 74 69 74 6c 65 3e 0a 3c 2f 68 65 61 or</title>.</hea
0160 64 3e 3c 62 6f 64 79 3e 0a 3c 68 31 3e 49 6e 74 d><body>.<h1>Int
0170 65 72 6e 61 6c 20 53 65 72 76 65 72 20 45 72 72 ernal Server Err
0180 6f 72 3c 2f 68 31 3e 0a 3c 70 3e 54 68 65 20 73 or</h1>.<p>The s
0190 65 72 76 65 72 20 65 6e 63 6f 75 6e 74 65 72 65 erver encountere
01a0 64 20 61 6e 20 69 6e 74 65 72 6e 61 6c 20 65 72 d an internal er
01b0 72 6f 72 20 6f 72 0a 6d 69 73 63 6f 6e 66 69 67 ror or.misconfig
01c0 75 72 61 74 69 6f 6e 20 61 6e 64 20 77 61 73 20 uration and was
01d0 75 6e 61 62 6c 65 20 74 6f 20 63 6f 6d 70 6c 65 unable to comple
01e0 74 65 0a 79 6f 75 72 20 72 65 71 75 65 73 74 2e te.your request.
01f0 3c 2f 70 3e 0a 3c 70 3e 50 6c 65 61 73 65 20 63 </p>.<p>Please c
0200 6f 6e 74 61 63 74 20 74 68 65 20 73 65 72 76 65 ontact the serve
0210 72 20 61 64 6d 69 6e 69 73 74 72 61 74 6f 72 20 r administrator
0220 61 74 20 0a 20 79 6f 75 40 65 78 61 6d 70 6c 65 at . you@example
0230 2e 63 6f 6d 20 74 6f 20 69 6e 66 6f 72 6d 20 74 .com to inform t
0240 68 65 6d 20 6f 66 20 74 68 65 20 74 69 6d 65 20 hem of the time
0250 74 68 69 73 20 65 72 72 6f 72 20 6f 63 63 75 72 this error occur
0260 72 65 64 2c 0a 20 61 6e 64 20 74 68 65 20 61 63 red,. and the ac
0270 74 69 6f 6e 73 20 79 6f 75 20 70 65 72 66 6f 72 tions you perfor
0280 6d 65 64 20 6a 75 73 74 20 62 65 66 6f 72 65 20 med just before
0290 74 68 69 73 20 65 72 72 6f 72 2e 3c 2f 70 3e 0a this error.</p>.
02a0 3c 70 3e 4d 6f 72 65 20 69 6e 66 6f 72 6d 61 74 <p>More informat
02b0 69 6f 6e 20 61 62 6f 75 74 20 74 68 69 73 20 65 ion about this e
02c0 72 72 6f 72 20 6d 61 79 20 62 65 20 61 76 61 69 rror may be avai
02d0 6c 61 62 6c 65 0a 69 6e 20 74 68 65 20 73 65 72 lable.in the ser
02e0 76 65 72 20 65 72 72 6f 72 20 6c 6f 67 2e 3c 2f ver error log.</
02f0 70 3e 0a 3c 2f 62 6f 64 79 3e 3c 2f 68 74 6d 6c p>.</body></html
0300 3e 0a >.
THope this gives you a clou what is wrong.
Link to comment
Share on other sites

HTTP/1.1 500 Internal Server Error

 

Something's wrong on the receiving end. Your request is fine. Who is in charge of the server you're sending requests to?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...