连接到Web服务-将C#转换为PHP代码

连接到Web服务-将C#转换为PHP代码,c#,php,web-services,wcf,soap,C#,Php,Web Services,Wcf,Soap,我有一个样本代码,我从一个商人提供的文档中得到。我想代码是用C#写的。我需要为PHP编写一个代码,但我对C毫无概念,所以我在这方面遇到了问题。我曾试图为此编写一个PHP代码,但它似乎不正确 顺便说一下,这是一种webservice类型的设置,它使用WCF公开各种端点。以下是他们向我提供的端点: 这是C代码: 任何关于如何解决这一问题的想法都将不胜感激。谢谢。你的肥皂剧好吗?尝试使用@Ohgodwhy我尝试使用is_soap_fault,但它没有输出任何内容,所以我猜soap调用没有问题。 pub

我有一个样本代码,我从一个商人提供的文档中得到。我想代码是用C#写的。我需要为PHP编写一个代码,但我对C毫无概念,所以我在这方面遇到了问题。我曾试图为此编写一个PHP代码,但它似乎不正确

顺便说一下,这是一种webservice类型的设置,它使用WCF公开各种端点。以下是他们向我提供的端点:

这是C代码:


任何关于如何解决这一问题的想法都将不胜感激。谢谢。

你的肥皂剧好吗?尝试使用@Ohgodwhy我尝试使用is_soap_fault,但它没有输出任何内容,所以我猜soap调用没有问题。
public bool SubmitLead(string contactName, string contactNumber) {

    bool outcome = false;
    string message = string.Empty;

    if (contactNumber.Length <= 9) {
        message = "Telephone number is too short";
        outcome = false;
    } else if (contactNumber.Length > 11) {
        message = "Telephone number is too long";
        outcome = false;
    } else if (contactNumber.Length == 10 && contactNumber[0] != '0') {
        message = "Telephone must start with a ZERO";
        outcome = false;
    } else if (contactNumber.Length == 11 && contactNumber.Substring(0, 2) != "27") {
        message = "Telephone must start with a 27";
        outcome = false;
    } else {
        WSExternalLead.LeadRequestMessage request = new
        WSExternalLead.LeadRequestMessage();
        request.Message = “Your Keyword” + ". Contact Name: " + contactName + ".
        Contact Number: " + contactNumber;
        request.TelephoneNumber = contactNumber;
        request.Network = “IMU”;
        request.ReceivedTime = DateTime.Now;

        using (WSExternalLead.ExternalLeadClient client = new WSExternalLead.ExternalLeadClient()) {

            try {
                WSExternalLead.LeadResponseMessage response = null;
                response = client.GenerateLead(request);

                if (response.Result != true) {
                    message = "We were unable to process your request at this
                    time. Error: " + response.ErrorMessage;
                    outcome = false;
                } else {
                    message = "Thank you for your interest in Scorpion Legal
                    Protection. We will get back to you shortly.";
                    outcome = true;
                }
            } catch (FaultException fx) {
                message = "We were unable to process your request at this time.
                Fault: " + fx.Message;
                outcome = false;
            } catch (Exception ex) {
                message = "We were unable to process your request at this time.
                Exception: " + ex.Message;
                outcome = false;
            }
        }
    }

    HttpContext.Current.Session["OUTCOME"] = outcome;
    HttpContext.Current.Session["MESSAGE"] = message;

    return outcome;
}
// Read values to variables
$username = $_GET['un'];
$usersurname = $_GET['ul'];
$phonesubmit= $_GET['up'];
$useremail = $_GET['ue'];
$aff_id = $_GET['aff'];
$unique_id = $_GET['uid'];
$rdate = date('m/d/Y G:i:s');
$rdate = date("c", strtotime($rdate));

$wsdlFile = "http://services.scorpion.biz/Public/Leads/ExternalLead.svc?WSDL"; 
$client = new SoapClient($wsdlFile);
$variables->TelephoneNumber = $phonesubmit; 
$variables->Message = "IMU. Name: $username $usersurname. Contact Number: $phonesubmit";
$variables->Network = "IMU";
$variables->ReceivedTime = $rdate;
$result = $client->GenerateLead($variables); 
$returnMessage = $result->Result;
$returnMessage = trim($returnMessage);
if ($returnMessage == ""){
    $returnMessage = $result->ErrorMessage;
}