0

I have the following php code which acts as proxy to my http server

slavePref.php

<?php
    $url = 'http://xyzdei/IPDWSRest/Service1.svc/getServerUtil';

    $callback = $_GET["callback"];
    echo($callback . "(");
    header('Content-Type: application/json; charset=utf8');
    echo(file_get_contents($url . '/' . $_GET["poolingServer"], $_GET["serverPID"]));

    echo (")");
    ?>

The webservice hosted on IIS has the following contract

   [OperationContract]
        [FaultContract(typeof(ExceptionOnIPDWS))]
        [WebInvoke(BodyStyle = WebMessageBodyStyle.WrappedRequest, UriTemplate = "getServerUtil/{poolingServer}&{serverPID}", ResponseFormat = WebMessageFormat.Json, Method = "GET")]
        //Status getServerUtil(string poolingServer,string serverPID, ref string oCreateResult); 
        string getServerUtil(string poolingServer, string serverPID); 

From the browser I am trying to call the uri as

http://:1136/slavePerf.php?poolingServer=thunderw7dei&serverPID=23456

However the request is failing with the following message

>

 Notice: Undefined index: callback in C:\Users\xom\Documents\My Web
> Sites\EmptySite2\slavePerf.php on line 4  ( Warning:
> file_get_contents(http://xomw764dei/IPDWSRest/Service1.svc/getServerUtil/thunderw7dei):
> failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in
> C:\Users\xom\Documents\My Web Sites\EmptySite2\slavePerf.php on line 8
> )

. I think I am not passing the arguments correctly

6
  • "However the request is failing" -> Errormessage? Commented Sep 11, 2014 at 9:20
  • 1
    @EdiG. I have updated the error message Commented Sep 11, 2014 at 9:23
  • 1
    Do you have parameter callback in your request part in URL? Commented Sep 11, 2014 at 9:30
  • 1
    @sameerkarjatkar then there is the problem no callback parameter in URL and you are trying to get non-existing parameter's value Commented Sep 11, 2014 at 9:34
  • 1
    Test: url with echo $url . '/' . $_GET["poolingServer"] . '&' . $_GET["serverPID"]; Commented Sep 11, 2014 at 9:39

2 Answers 2

1

You aren't setting a parameter called 'callback' and so it isn't set in the $_GET variables.

You could fix the error message by doing:

$callback = "";
if(array_key_exists('callback', $_GET) == TRUE){
    $callback = $_GET['callback'];
}

and add a '&' in the url:

echo(file_get_contents($url . '/' . $_GET["poolingServer"] . '&' . $_GET["serverPID"]))
Sign up to request clarification or add additional context in comments.

4 Comments

Now its reporting Warning: file_get_contents(xomw764dei/IPDWSRest/Service1.svc/getServerUtil/…): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in C:\Users\xom\Documents\My Web Sites\EmptySite2\slavePerf.php on line 8
Is my uri template in the webservice correct UriTemplate = "getServerUtil/{poolingServer}&{serverPID}"
The php response is file_get_contents(xomw764dei/IPDWSRest/Service1.svc/getServerUtil/…): failed to open stream: HTTP request failed! for the url localhost:1136/…
1

The problem was resolved when I modified my php file for file_get_contents

echo(file_get_contents($url . '/' . $_GET["poolingServer"]));

and my uriTemplate to

[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "getServerUtil/{poolingServer}/{serverPID}", ResponseFormat = WebMessageFormat.Json, Method = "GET")]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.