0

I'm trying to connect to a secured web service (HTTPS - TLS v3) but I'm getting this error:

Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://integrationdev.momentum.co.za/sales/CRMService/CRMLeadService_v1_0' : failed to load external entity "https://integrationdev.momentum.co.za/sales/CRMService/CRMLeadService_v1_0"

Here's the code that I've used:

$momurl = "integrationdev.momentum.co.za/sales/CRMService/CRMLeadService_v1_0";

//Perform Request
$client = new SoapClient(
  "https://" . urlencode($username) . ":" . urlencode($password) . "@$momurl",
      array(
          'login' => $username,
          'password' => $password
      )
 );

$params = new stdClass(); 
$params->LeadSourceId = $lsid;
$params->AffiliateLeadReference = $alref;
$params->Title = $title;
$params->Initials = $initials;
$params->PreferredName = $pname;
$params->FirstName = $username;
$params->LastName = $userlname;
$params->PreferredCorrespondenceLanguage = $lang;
$params->PreferredCommunicationMethod = $comm;
$params->Campaign = $camp;
$params->HomePhoneNumber = $phonesubmit;
$params->BusinessPhoneNumber = $phonesubmit;
$params->MobilePhoneNumber = $phonesubmit;
$params->EmailAddress = $useremail;
$params->Notes = $u_script;
$params->ProductCategories = $prodcat;

try { 
    $result = $client->createLead($params); 
} catch (Exception $e) { 
    $msgs = $e->getMessage();
    if($debug) echo "Error: $msgs"; 
} 

The code doesn't seem to work. I'm not so sure in the authentication part. Here's what the WSDL looks like:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="CRMLeadService" 
        targetNamespace="http://www.momentum.co.za/crm/service/application/CRMLeadService/v1.0" 
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
        xmlns:tns="http://www.momentum.co.za/crm/service/application/CRMLeadService/v1.0" 
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
        xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <wsdl:types>
        <xsd:schema targetNamespace="http://www.momentum.co.za/crm/service/application/CRMLeadService/v1.0" 
                    xmlns:lead="http://www.momentum.co.za/crm/service/type/application/Lead/v1.0" 
                    xmlns:systemFault="http://www.momentum.co.za/crm/service/type/fault/SystemFault/v1.0">

            <xsd:import namespace="http://www.momentum.co.za/crm/service/type/application/Lead/v1.0" schemaLocation="../xsd-src/Lead_1_0.xsd"/>
            <xsd:import namespace="http://www.momentum.co.za/crm/service/type/fault/SystemFault/v1.0" schemaLocation="../xsd-src/SystemFault_1_0.xsd"/>

            <xsd:element name="SystemFault_fault">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="system_fault" type="systemFault:SystemFaultMessageType"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="CreateLeadRequest">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="createLead" type="lead:LeadType"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="CreateLeadResponse">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="leadReferenceNumber" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>  
        </xsd:schema>
    </wsdl:types>

    <wsdl:message name="SystemFault_faultMsg">
        <wsdl:part element="tns:SystemFault_fault" name="parameters"/>
    </wsdl:message>

    <wsdl:message name="CreateLeadRequest">
        <wsdl:part element="tns:CreateLeadRequest" name="parameters"/>
    </wsdl:message>

    <wsdl:message name="CreateLeadResponse">
        <wsdl:part element="tns:CreateLeadResponse" name="parameters"/>
    </wsdl:message>

    <wsdl:portType name="CRMLeadService_v1_0">

        <wsdl:operation name="createLead">
            <wsdl:documentation>Creates lead on CRM</wsdl:documentation>
            <wsdl:input message="tns:CreateLeadRequest" name="CreateLeadRequest"/>
            <wsdl:output message="tns:CreateLeadResponse" name="CreateLeadResponse"/>
            <wsdl:fault message="tns:SystemFault_faultMsg" name="systemFault"/>
        </wsdl:operation>

    </wsdl:portType>

    <wsdl:binding name="CRMLeadServiceSOAP_v1_0" type="tns:CRMLeadService_v1_0">

        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

        <wsdl:operation name="createLead">
            <soap:operation soapAction="http://www.momentum.co.za/crm/service/application/CRMLeadService/createLead"/>
            <wsdl:input name="CreateLeadRequest">
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="CreateLeadResponse">
                <soap:body use="literal"/>
            </wsdl:output>
            <wsdl:fault name="systemFault">
                <soap:fault name="systemFault" use="literal"/>
            </wsdl:fault>
        </wsdl:operation>

    </wsdl:binding>

    <wsdl:service name="CRMLeadService_v1_0">
        <wsdl:documentation>Provides operation that enables the creation of leads on CRM</wsdl:documentation>
        <wsdl:port binding="tns:CRMLeadServiceSOAP_v1_0" name="CRMLeadServiceSOAP_v1_0">
            <soap:address location="http://localhost:9080/WebToLeadServiceSOAP/services/CRMLeadService_v1_0"/>
        </wsdl:port>
    </wsdl:service>

</wsdl:definitions>

Am I doing this right? Any help would be very much appreciated. Thanks!

maikelsabido
  • 1,253
  • 4
  • 18
  • 37
  • Have you tried using any SOAP UI client to test the wsdl ? – Vineet Singla Sep 13 '13 at 11:35
  • Hmmm... I'm actually not familiar with SOAP UI clients and I don't know how to use them. Can you help me with this? I really need to get this working. – maikelsabido Sep 14 '13 at 07:25
  • The URL of the WSDL is unreachable. In this state it cannot work. Are you sure you are using the correct URL? Can you use a browser and get the WSDL from that location? – Sven Sep 14 '13 at 22:42
  • 1
    Download from soapui.org - you can get it for some sort period. From there you can test ur wsdl – Vineet Singla Sep 16 '13 at 05:16

0 Answers0