function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
EMHDevEMHDev 

WSDL file problems

I modified an Apex class which was written by a contractor, to add an additional field to the class, using the Eclipse IDE.  When I then generated a new WSDL in salesforce, instead of just producing a WSDL for the class, it produced what looks like the Enterprise WSDL as well as my class.  Does anyone know why, and how I can correct this?  We are using the Partner WSDL in the code.

 

Secondly, the website doesn't seem to be loading the new WSDL as the additional field that all this trouble was for, is not being populated. I've checked the PHP test page and can't see anything wrong with it, but when we print the object, the new field does not appear.

 

I don't know if these two problems are related, has anyone else experienced something similar? Test page code below:

 

<body>

<?PHP

require_once ('sfdc/SforcePartnerClient.php');
require_once ('sfdc/SforceHeaderOptions.php');

// virtual user system admin
$sfdcUsername = "xxxxxxxxxxx";
$sfdcPassword = "yyyyyyyyyyyyyy";
$sfdcToken = "zzzzzzzzzzzzzz";

//$emailToFetch = "fetchbyemail@noemail.com";
$emailToFetch = "jobyrblume@hotmail.com";
//echo $emailToFetch;

$sfdc = new SforcePartnerClient();
$SoapClient = $sfdc->createConnection("sfdc/partner.wsdl.xml");
$loginResult = false;
$loginResult = $sfdc->login($sfdcUsername, $sfdcPassword.$sfdcToken);

$parsedURL = parse_url($sfdc->getLocation());
define ("_SFDC_SERVER_", substr($parsedURL['host'],0,strpos($parsedURL['host'], '.')));
define ("_WS_NAME_", "SubscriptionService");
define ("_WS_WSDL_", "sfdc/" . _WS_NAME_ . ".wsdl.xml");
define ("_WS_ENDPOINT_", 'https://' . _SFDC_SERVER_ . '.salesforce.com/services/wsdl/class/' . _WS_NAME_);
define ("_WS_NAMESPACE_", 'http://soap.sforce.com/schemas/class/' . _WS_NAME_);

// SOAP Client for Web Service
$client = new SoapClient(_WS_WSDL_);
$sforce_header = new SoapHeader(_WS_NAMESPACE_, "SessionHeader", array("sessionId" => $sfdc->getSessionId()));
$client->__setSoapHeaders(array($sforce_header));

try {
$wsParams=array('email'=>$emailToFetch);
$response = $client->fetchByEmail($wsParams);
// set a variable to store how many results were returned
$resultsSize = sizeOf($response->result);

$id = $response->result->id;
$firstName = $response->result->firstName;
$lastName = $response->result->lastName;
$company = $response->result->company;
$country = $response->result->country;
$email = $response->result->email;
$phone = $response->result->phone;
$newsletter = $response->result->newsletter;
$slides = $response->result->slides;
$whitepapers = $response->result->whitepapers;
$events = $response->result->events;
$speialOffers = $response->result->specialOffers;
$weeklyDigest = $response->result->weeklyDigest;
$subsChanged = $response->result->subsChanged;
$sObjectType = $response->result->sObjectType; // this will either be 'Contact' or 'Lead'
$error = $response->result->error;
$errorMessage = $response->result->errorMessage;
echo '<p>Name: '.$firstName.'</p>';
echo '<p>Subs changed: '.$subsChanged.'</p>';

} catch (Exception $e) {
global $errors;
$errors = $e->faultstring;
echo "Ooop! Error: <b>" . $errors . "</b>"; // fatal exception. log it to somewhere or send email
die;
}

if ($resultsSize == 1) {
if ($response->result->error == 1) { ?>
<p>There were no results returned for the address <? echo $emailToFetch ?></p>
<p>Please check and try again</p>
<form action="<? $_SERVER['PHP_SELF'] ?>" method="post" class="subs-form">
<input name="subscription_address" id="subscription_address" type="text" size="30"/><input type="submit" name="submit" value="Submit" class="contact-button"/>
</form>
<p>If the form is unable to return your subscription please <a href="#">contact us</a></p>
<?
} else {
print_r($response);
}
} else { // Multiple Results!!!?>
<p>There were <? echo $resultsSize; ?> results returned for the email address <? echo $response->result[0]->email; ?></p>
<p>Please enter your personal details to select your record.</p>

<?
}
?>


</body>

 The class looks like this:

 

global class Subscriber {

webservice String id;
webservice String firstName;
webservice String lastName;
webservice String company;
webservice String country;
webservice String email;
webservice String phone;
webservice Boolean newsletter;
webservice Boolean slides;
webservice Boolean whitepapers;
webservice Boolean events;
webservice Boolean specialOffers;
webservice Boolean weeklyDigest;
webservice Date subsChanged;
webservice String sObjectType;
webservice Boolean error;
webservice String errorMessage;

}

 

 subsChanged is the new field in there.  The class passes the test methods and appears to be sitting happily in salesforce, before I made this change, everything was working happily.

 

I'd be really grateful for any advice.  This is my first foray into Apex web services and so far it isn't a happy one!

 

Erica