Solved

PHP5 > Using SoapClient() to make request

Posted on 2009-04-02
8
1,258 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
[X]
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
  • 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 

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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

724 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