Solved

PHP5 > Using SoapClient() to make request

Posted on 2009-04-02
8
1,248 Views
Last Modified: 2013-11-18
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
Comment
Question by:Geoff Millikan
  • 5
  • 3
8 Comments
 
LVL 3

Expert Comment

by:garlix
ID: 24058867
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
 

Author Comment

by:Geoff Millikan
ID: 24063673
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
 
LVL 3

Expert Comment

by:garlix
ID: 24066000
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
 

Author Comment

by:Geoff Millikan
ID: 24072938
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 3

Accepted Solution

by:
garlix earned 500 total points
ID: 24074744
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
 
LVL 3

Expert Comment

by:garlix
ID: 24114255
Did you get it to work? :)
0
 

Author Comment

by:Geoff Millikan
ID: 24118892
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
 
LVL 3

Expert Comment

by:garlix
ID: 24156482
Cool! Good luck!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now