VMware Cloud Community
streki
Contributor
Contributor

contact Web service of a vCenter

Hello,

I'm not sure, it the good location for my post..

anyway, I'm begining using webService to interact with my esx 4.1.

This one is under a vCenter.

I'm interacting through php script with soap client.

Here is my code :

<?php
$serverIP = "XXX";
$serverUser = "XXX";
$serverPassword = "XXX";
$client = new SoapClient("https://$serverIP/sdk/vimService.wsdl", array("trace" => 1, "location" => "https://$serverIP/sdk/") ); $soapmsg["_this"] = array( "_" => "ServiceInstance", "type" => "ServiceInstance"); $result = $client->RetrieveServiceContent($soapmsg); $ServiceContent = $result->returnval; $soapmsg = NULL;
$soapmsg["_this"] = $ServiceContent->sessionManager;
$soapmsg["userName"] = $serverUser;
$soapmsg["password"] = $serverPassword; $result = $client->Login($soapmsg); $UserSession = $result->returnval; echo "User " . $UserSession->userName . " is connected\n";$soapmsg = NULL;
$soapmsg["_this"] = $ServiceContent->sessionManager;
$result = $client->Logout($soapmsg);
?>

It work well directly on my esx, but when I try to login to the WS of my vCenter, (replacing the credentials) I've got the following error:

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from 'https://192.168.10.12/sdk/reflect-messagetypes.xsd' in /root/VMwarePHPWebServices/vmwareTestAPI.php:10
Stack trace:
#0 /root/VMwarePHPWebServices/vmwareTestAPI.php(10): SoapClient->SoapClient('https://192.168...', Array)
#1 {main}
  thrown in /root/VMwarePHPWebServices/vmwareTestAPI.php on line 10

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I looked on the web and other people faced this problems, it seems to be the fault of the WSDL file syntax?

http://www.devraju.com/programming/fatal-error-uncaught-soapfault-exception-wsdl-soap-error-parsing-...

I wondered if this problem is knowed, I am on the good track, do someone have a solution?

Or maybe it's not the same way to contact the vCenter?

Thanks in advance!

0 Kudos
7 Replies
chriskatsuo0905
Contributor
Contributor

Hello,

I have the exact same problem than streki, and it prevents me to do any web service call to the vCenter.

As anyone a solution for this problem please ?

Actually, on my side, whatever it is on the ESXI or the vCenter, the resource

https://<IP>/sdk/reflect-messagetypes.xsd

causes a 404 error

It looks like this error is ignored when connecting to the ESXI but causes a fatal error when contacting the vCenter.

I don't know if it is related but there is the following difference between the ESXI WSDL and the vCenter WSDL:

on "<schema" tag of the vCenter, there is an additional attribute

xmlns:reflect="urn:reflect"

Thanks in advance for your answers, it is very urgent for us.

Best regards,

Christophe

0 Kudos
chriskatsuo0905
Contributor
Contributor

Hello,

Actually, there is an additional tag in the vCenter WSDL:

<import namespace="urn:reflect" schemaLocation="reflect-messagetypes.xsd"/>

so I guess it's the cause of the problem.

So the question is:

why accessing the reflect-messagetypes.xsd cause a 404 error on the vCenter ?

Is it an installation error ? is there a way to fix this ?

Thanks in advance for your help on this issue.

Best regards,

Christophe

0 Kudos
chriskatsuo0905
Contributor
Contributor

Hello,

I posted two workarounds to this issue in the following post:

http://communities.vmware.com/message/1876130#1876130

Best regards,

Christophe

0 Kudos
streki
Contributor
Contributor

Thanks for your answer!

But since the last post I change my approach, I'm now working with JAVA and the viJava API from Steve Jin:

http://vijava.sourceforge.net/

It's a lot more easy to use!

0 Kudos
digitalaudioroc
Contributor
Contributor

In vSphere 5 the error regarding the reflect-messagetypes.xsd is due to a known issue, where the server side wsdl is incomplete (missing files as I found):

http://www.vmware.com/support/developer/vc-sdk/wssdk_5_0_releasenotes.html#knownissues

See the second issue there:

  • "vSphere 5.0 Server WSDL files obtained directly from a Server are not complete.

    It is possible to retrieve the vSphere API WSDL files from an ESXi or vCenter Server. These WSDL files are not complete. You cannot use the server-based WSDL; SOAP toolkits cannot process it correctly because the Server does not have a complete set of the schema files. The vSphere Web Services SDK contains a complete WSDL file configuration (WSDL and schema files), located in the following directory of the vSphere Management SDK distribution:

        VMware-vSphere-SDK-5.0.0-429209\SDK\vsphere-ws\wsdl\vim25\"

  • In our case, downloading the SDK referenced above and adding the missing files on the vcenter server (reflect-types.xsd and reflect-messagetypes.xsd) in the sdk directory under the docroot corrected this.

    Tom

    0 Kudos
    chriskatsuo0905
    Contributor
    Contributor

    Hello,

    Thank you very much for your answer Tom !

    Best regards,

    Christophe

    0 Kudos
    tetrapackage
    Contributor
    Contributor

    Thanks for a very informative solution and also for the link where I can check more about such problem. Good job. Smiley Wink

    0 Kudos