Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PHP5 > Using SoapClient() to make request

Posted on 2009-04-02
8
1,256 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

840 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