Jump to content
Sign in to follow this  


Recommended Posts


I use PocketXML-RPC for send requests to an XML-RPC server.

I have a problem with this ligne :

$b = $response."711".name ;Error referenced outside a "With" statement.

When I execute the script I have this error : Error referenced outside a "With" statement.

I have wrote the same code in php (with COM) and no problem, I can access to the value.

I don't know how solve this problem.

#cs ----------------------------------------------------------------------------

 AutoIt Version:
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

Func Connect ()

    Dim $data[50]
    Dim $response[50]

    $f = ObjCreate("pocketXMLRPC.Factory")
    $p = $f.Proxy("http://localhost/testlink/lib/api/xmlrpc.php", "tl.")

    $r = $p.ping() ;ping the server

    MsgBox(4096, "Web Service Response", $r, 10) ;ok
    $myStruct = ObjCreate("PocketXMLRPC.Struct")
    $myStruct.devKey = "6e532660fab75f7057d3b753a04eac3c"
    $myStruct.testplanid = 709;
    $myStruct.testcasename = "tcTestJu"
    $response = $p.getTestCaseIDByName($myStruct) ;ok
    MsgBox(0,"",$response[0].id) ;$response[0].id = 711
    $response = $p.getTestCasesForTestPlan($myStruct)
    $b = $response."711".name ;Error referenced outside a "With" statement.

Connect ()

For help the response in php:

POST /testlink/lib/api/xmlrpc.php HTTP/1.0
Host: localhost
Content-Type: text/xml
User-Agent: Incutio XML-RPC
Content-length: 342

<?xml version="1.0"?>

<?xml version="1.0"?>


Share this post

Link to post
Share on other sites

This was the best I found, for error similar to yours:


Perhaps it is a COM error, and AutoIt is reporting the error with a vague message.

In the meantime, since AutoIt is very similar to VBScript and you are not using anything feature specific to AutoIt, perhaps you can port your code into VBScript and run that and see if it works or what error message you get.

Share this post

Link to post
Share on other sites

Thanks for your reply.

I don't know VBScript but if I find the time I will try.

I have port this code into php and I have no error, I think it's not a COM error.

Share this post

Link to post
Share on other sites

Personally, I find COM error handling (at least in the case where other languages like VBScript, and AutoIt fail to catch COM errors) is best handled by JScript (on Windows Scripting Host (WSH) or Javascript in general). If you know JScript, you could port your code into JScript running as WSH script and see how that goes, catching COM error in your code using the try/catch block in JScript around your code.

Share this post

Link to post
Share on other sites

Yes I think too that the error message is not clear. If it's ok in php there is no reason for have a problem with vb or jscript.

Maybe it's a parse problem with AutoIt.

Share this post

Link to post
Share on other sites

Ju72, it may be useful to post the PHP version of the code where you use the COM object to compare. Perhaps PHP is more flexible in how you call COM object properties/methods compared to AutoIt, like in the case of "711" property as Richard mentions.

Richard, any ideas how to access property "711" in this case then? I don't work with XML-RPC myself, but I guess it's just accessing the "711" node branch from the PHP response output returned? Using XML DOM navigation and/or XPath, something like that?

Share this post

Link to post
Share on other sites

As far as I know, AutoIt can't call things like that due to the structure of the language. It doesn't even sound like a valid property name in the first place though.

I actually don't have much experience in COM, but from other languages, I have seen that identifiers shouldn't start with numbers.

Share this post

Link to post
Share on other sites


Thanks for your help.

My code in php:

    $f = new COM("pocketXMLRPC.Factory");

    $p = $f->Proxy("http://localhost/testlink/lib/api/xmlrpc.php", "tl.");

    $r = $p->ping();
    echo $r;
    $Struct = new COM("PocketXMLRPC.Struct");
    $TabReponse = array ();
    $Struct->devKey = "6e532660fab75f7057d3b753a04eac3c";
    $Struct->testplanid = 709;
    $TabReponse = $p->getTestCasesForTestPlan($Struct);
    $a = "711";
    echo $TabReponse->$a->name; //Print the result


This code works:

$a = "711";
    echo $TabReponse->$a->name; //Print the result

This code doesn't works:

echo $TabReponse->"711"->name; //Print the result

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `'{'' or `'$'' in D:\wamp\www\testCOM.php on line 41

I have try that with AutoIt

$a = "711"
    $b = $response.$a.name

But I have an error:

$b =^ERROR

Error: Error in expression.

And this

Dim $a[1]
    $a[0] = "711"
    $b = $response.$a[0].name


$b = $reponse.$a[0]^ERROR

Error referenced outside a "With" statement.

I have found this link: COM Reference

Can you tell me if this can help me:


The WITH/ENDWITH statement does not add functionality, but it makes your script easier to read. For instance, the previous example using Excel can also be written as:

$oExcel = ObjCreate("Excel.Application") ; Create an Excel Object

WITH $oExcel

.Visible = 1 ; Let Excel show itself

.WorkBooks.Add ; Add a new workbook

.ActiveWorkBook.ActiveSheet.Cells(1,1).Value="test" ; Fill a cell

sleep(4000) ;See the results for 4 seconds

.ActiveWorkBook.Saved = 1 ; Simulate a save of the Workbook

.Quit ; Quit Excel


This example does not save you a lot of text, but when your object uses long lines of properties/methods, you can shorten it heavily within a WITH statement.

Share this post

Link to post
Share on other sites

Well, since AutoIt is very identical to VBScript, the solution to both may be similar.

In VBScript, response."711".name is likely invalid as well. Typically, I think one would reference that more like something like this:



The only problem here is figuring out the property collection name to use to specify the node/property "711" of interest (e.g. is it item, node, or something else?). Since we are talking about XML-RPC and specific library being used, I wouldn't know the proper reference method.

In terms of XML, one can look up how to access the desired node "711" for example by following the XML DOM reference. I assume it is similar for XML-RPC since it uses XML. One reference site for that would be http://www.w3schools.com/dom/dom_node.asp, there are other sites as well.

Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...