Solved

PHP5 > Using SoapClient() to make request

Posted on 2009-04-02
8
1,250 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

912 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

22 Experts available now in Live!

Get 1:1 Help Now