1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

SOAP client issue.

Discussion in 'PHP' started by stephan2307, Aug 22, 2018.

  1. #1
    For a client I need to use a SOAP API. Having real problems with it and wondering if someone can help with this.

    They have provided an example soap call that works but I can not get my code to match that example request. Can anyone point me in the right direction?

    Example SOAP request

    
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:hyp="http://xxxxxxxxxx">
      <soap:Header>
        <hyp:AuthSoapHeader>
          <hyp:strUserName>xxxxx</hyp:strUserName>
          <hyp:strPassword>xxxxxx</hyp:strPassword>
        </hyp:AuthSoapHeader>
      </soap:Header>
      <soap:Body>
        <hyp:Ws_CreateCard>
          <hyp:WSID>xxxx</hyp:WSID>
          <hyp:IssCode>xxx</hyp:IssCode>
        </hyp:Ws_CreateCard>
      </soap:Body>
    </soap:Envelope>
    
    Code (markup):
    My code sends the following request
    SEMrush
    
    <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="xxxxxxx" xmlns:ns2="xxxxxx">
        <env:Header>
            <ns2:AuthSoapHeader>
                <item>
                    <key>strUserName</key>
                    <value>xxxx</value>
                </item>
                <item>
                    <key>strPassword</key>
                    <value>xxxxxxx</value>
                </item>
            </ns2:AuthSoapHeader>
        </env:Header>
        <env:Body>
            <ns1:Ws_CreateCard>
                <ns1:WSID>xxxx</ns1:WSID>
                <ns1:IssCode>xxxxx</ns1:IssCode>
            </ns1:Ws_CreateCard>
        </env:Body>
    </env:Envelope>
    
    Code (markup):
    And this is my code
    
    $opts = array(
                 'http' => array(
                     'user_agent' => 'PHPSoapClient'
                 ),
                 'ssl' => array(
                    'verify_peer' => false,
                    'verify_peer_name' => false,
                    'allow_self_signed' => true
                  )
                );
    
            $context = stream_context_create($opts);
    
            $soapClientOptions = array(
              'stream_context' => $context,
              'cache_wsdl' => WSDL_CACHE_NONE,
              'trace' => 1,
              'soap_version' => SOAP_1_2,
              'uri'=>'http://www.w3.org/2003/05/soap-envelope',
              'style'=>SOAP_RPC,
              'encoding'=>'UTF-8'
    
            );
    
            $client = new SoapClient($endpoint, $soapClientOptions);
    
            $soapAuth = array( 'strUserName' => $username,
                               'strPassword' => $password
                             );
                             
    
            $header     = new SoapHeader($endpoint, 'AuthSoapHeader', $soapAuth, false);
    
            $result = $client->__soapCall('WS_CreateCard', array( 'WS_CreateCard' => array(
                'WSID' => 'xxxx',
                'IssCode' => 'xxxx'
    )
                  ) , NULL, $header);
    
    PHP:
    Any idea where I am going wrong?

    Thanks
     
    stephan2307, Aug 22, 2018 IP
    SEMrush
  2. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,252
    Likes Received:
    26
    Best Answers:
    7
    Trophy Points:
    150
    #2
    Its ok. Thanks.
    rewritten the code and am using curl now.
     
    stephan2307, Aug 22, 2018 IP