[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1266
  • Last Modified:

PHP5 > Using SoapClient() to make request

Would you please show me your way of using SoapClient() to build the attached XML getDedicatedIntAccessQuote_v4() request?

I don't need a full working example (although that would be nice), just the structure of how you'd suggest we get started.
<?PHP
//# This code returns the functions below.  The function I want to use is the getDedicatedIntAccessQuote_v4() function/method.
 
$client = new SoapClient("https://tools.xo.com/click2quote/services/ProductBean?wsdl");
print_r($client->__getFunctions());
?>
 
Array
(
    [0] => getBusinessLinesQuote_v3Response getBusinessLinesQuote_v3(getBusinessLinesQuote_v3 $parameters)
    [1] => getDedicatedIntAccessQuote_v4Response getDedicatedIntAccessQuote_v4(getDedicatedIntAccessQuote_v4 $parameters)
    [2] => getDedicatedLDQuote_v3Response getDedicatedLDQuote_v3(getDedicatedLDQuote_v3 $parameters)
    [3] => getISDNPRIQuote_v3Response getISDNPRIQuote_v3(getISDNPRIQuote_v3 $parameters)
    [4] => getIpVpnQuoteResponse getIpVpnQuote(getIpVpnQuote $parameters)
    [5] => getIpVpnQuote_v2Response getIpVpnQuote_v2(getIpVpnQuote_v2 $parameters)
    [6] => getManagedFirewallQuote_v3Response getManagedFirewallQuote_v3(getManagedFirewallQuote_v3 $parameters)
    [7] => getMplsWithFlexQuoteResponse getMplsWithFlexQuote(getMplsWithFlexQuote $parameters)
    [8] => getMplsWithFlexQuote_v2Response getMplsWithFlexQuote_v2(getMplsWithFlexQuote_v2 $parameters)
    [9] => getPointToPointQuote_v3Response getPointToPointQuote_v3(getPointToPointQuote_v3 $parameters)
    [10] => getSipTrunksQuoteResponse getSipTrunksQuote(getSipTrunksQuote $parameters)
    [11] => getSwitchedDigitalTrunksT1Quote_v3Response getSwitchedDigitalTrunksT1Quote_v3(getSwitchedDigitalTrunksT1Quote_v3 $parameters)
    [12] => getTollFreeQuote_v3Response getTollFreeQuote_v3(getTollFreeQuote_v3 $parameters)
    [13] => getVpnQuote_v3Response getVpnQuote_v3(getVpnQuote_v3 $parameters)
    [14] => getXOptionsFlexQuoteResponse getXOptionsFlexQuote(getXOptionsFlexQuote $parameters)
)

Open in new window

xml-request-sample.txt
0
Geoff Millikan
Asked:
Geoff Millikan
  • 5
  • 3
1 Solution
 
garlixCommented:
Hello!
The code below describes how you make a simple SOAP-request.

The args-array is your request. Some SOAP-services seems to require that you send the request-arguments as array('arguments' => $args)

Notice I pass "array('trace' => true)" as argument to SoapClient. This allows you to type:
$client->__getLastRequest();

To see the actual request that was sent to the SOAP-serivce. Very good for debug! Takes a bit tweaking to get things perfect sometimes :-)

I've not tested the code - alas. But it shows the basics for a simple SOAP request :)

Good luck!

<?php
$client = new SoapClient("https://tools.xo.com/click2quote/services/ProductBean?wsdl", array('trace' => true));
 
$args = 
	array(
	  array('DedicatedIntAccessQuoteRequest_v3_1' =>
	     array(
			'address' =>
				array('addressLine1' => '2700 Summit avenue',
				'addressLine2' => ''),
			'contactTn' =>
				array('emailAddress' => '',
					  'firstName'    => '')
			)
		)
	);
 
$client->getDedicatedIntAccessQuote_v4Response($args);
?>

Open in new window

0
 
Geoff MillikanAuthor Commented:
Awesome!  I setup it all up but I'm getting the error below on my code below:

At line number: 24 SOAP Fault: (faultcode: Client, faultstring: Function ("getDedicatedIntAccessQuote_v4Response") is not a valid method for this service)
<?PHP
try {
	$client = new SoapClient("https://tools.xo.com/click2quote/services/ProductBean?wsdl", array('trace' => true));
} catch (SoapFault $fault) {
	echo "<hr>At line number: ".__LINE__." SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})"; 
	exit();
}
 
$args = array(
          array('DedicatedIntAccessQuoteRequest_v3_1' =>
             array(
             'address'   => array('addressLine1' => '2700 Summit avenue', 'addressLine2' => '', 'city'=>'Plano', 'state'=>'TX','zip'=>'75074'),
             'contactTn' => array('emailAddress' => 'sample@example.com', 'firstName' => 'Roger', 'lastName'=>'Trimble', 'workPhone'=>'','companyName'=>'C2Q Company Name','line'=>'6309','npa'=>'972','nxx'=>'578'),
             'login_v3' => array('agentId' => 'U1012', 'partnerId' => 'napttest', 'partnerPassword'=>'napttest', 'partnerRequestId'=>'','subAgentCompanyName'=>'Sub Agent 1'),
             'product' => array('circuitSpeed' => 'DS1', 'productName' => 'DEDICATED INTERNET ACCESS', 't1Multiplier'=>'1', 'state'=>'','zip'=>''),
             'purchaseOrderNumber' => array('purchaseOrderNumber' => 'PO 1234')
             )
          )
        );
 
try {
    $client->getDedicatedIntAccessQuote_v4Response($args);    
} catch (SoapFault $fault) {  
    echo "<hr>At line number: ".__LINE__." SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})";
    echo '<hr><pre>';
    var_dump($client->__getLastRequest());
    echo '</pre>';
    exit();
}
 
echo '<hr><pre>';
var_dump($client->__getLastRequest());
echo '</pre>';
 
echo '<hr><pre>';
print_r($client);
echo '</pre>';
 
exit();
?>

Open in new window

0
 
garlixCommented:
Oh, doh.

My bad. Call ought to be "getDedicatedIntAccessQuote" without the respond behind it :)

getDedicatedIntAccessQuote_v4(getDedicatedIntAccessQuote_v4 $parameters)

Am not 100% sure about the layout of your request. But judging from the sample-request, your request seems about right!

Also a bit unsure about the initial array. try code below:

$args = array('DedicatedIntAccessQuoteRequest_v3_1' =>
             array(
             'address'   => array('addressLine1' => '2700 Summit avenue', 'addressLine2' => '', 'city'=>'Plano', 'state'=>'TX','zip'=>'75074'),
             'contactTn' => array('emailAddress' => 'sample@example.com', 'firstName' => 'Roger', 'lastName'=>'Trimble', 'workPhone'=>'','companyName'=>'C2Q Company Name','line'=>'6309','npa'=>'972','nxx'=>'578'),
             'login_v3' => array('agentId' => 'U1012', 'partnerId' => 'napttest', 'partnerPassword'=>'napttest', 'partnerRequestId'=>'','subAgentCompanyName'=>'Sub Agent 1'),
             'product' => array('circuitSpeed' => 'DS1', 'productName' => 'DEDICATED INTERNET ACCESS', 't1Multiplier'=>'1', 'state'=>'','zip'=>''),
             'purchaseOrderNumber' => array('purchaseOrderNumber' => 'PO 1234')
             )
          )

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Geoff MillikanAuthor Commented:
Rats.  I tried it, same error.  Seems like the error isn't indicating that the args are malformed, it seems like it's saying that we should not be calling the getDedicatedIntAccessQuote_v4Response() method at all!  

But it is a valid method, right?  Because we can see it declared when we show all the functions of the service with:

print_r($client->__getFunctions());

SOAP is so complicated like this - seems like we're always having to guess and guess at stuff like this.  SOAP is not intuitive.
At line number: 35 SOAP Fault: (faultcode: Client, faultstring: Function ("getDedicatedIntAccessQuote_v4Response") is not a valid method for this service)

Open in new window

0
 
garlixCommented:
Yes, that's what I said in my previous comment! I realized I had missread that part!

Quoting myself,

"Oh, doh.

My bad. Call ought to be "getDedicatedIntAccessQuote" without the respond behind it :)

getDedicatedIntAccessQuote_v4(getDedicatedIntAccessQuote_v4 $parameters)"

Try without Response on the end! :-)
0
 
garlixCommented:
Did you get it to work? :)
0
 
Geoff MillikanAuthor Commented:
Yes, I think so - but based on response below, either we're sending a malformed request or the unsername/password we're trying to use is bad.  So we're waiting on system engineers to tell us which one it is.  So I was hoping to keep this open a bit longer - we're defiantly on the right track!
    <c2qError>
     <error>true</error>
     <errorId>20000</errorId>
     <errorMessage>The server could not authenticate the user : napttest</errorMessage>
     <requestId xsi:nil="1"/>
    </c2qError>

Open in new window

0
 
garlixCommented:
Cool! Good luck!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now