Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting error in SOAP client 1

Status
Not open for further replies.

tlhawkins

Programmer
Dec 28, 2000
797
US
Hey,

I'm a bit of a SOAP retard when it comes to PHP having been spoiled by .NET so please bear with me.

Here is how I'm creating my request:
Code:
$SC = new SoapClient('[URL unfurl="true"]http://staging.tgpolicywebsvcs.travelguard.com/tgpolicyservice.asmx?WSDL',[/URL] array("soap_version" => SOAP_1_2));
$returnValue = $SC->__soapCall('getQuoteXML', array('parameters' => $getQuote));

Here is the error I'm getting:
Fatal error: Uncaught SoapFault exception: [soap:Receiver] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentNullException: Value cannot be null. Parameter name: s at System.IO.StringReader..ctor(String s) at System.Xml.XmlDocument.LoadXml(String xml) at Noel.Web.Services.TGPolicyService.GetPolicy(String xml) at Noel.Web.Services.TGPolicyService.GetQuote(String xml) at Noel.Web.Services.TGPolicyService.GetQuoteXML(String data) --- End of inner exception stack trace ---

Any idea what this parameter 's' is that is Null?
I've tried everything I can think of without getting any real difference in the error.

Thanks for any help

Travis Hawkins
jobs.bestcodingpractices.com
 
ok... I've looked at all the data in the WSDL and operation pages. My problem is, I don't know how to reproduce what it's asking for in PHP.

I can call getTypes and getFunctions, those work fine, but when I call getQuote I get errors. So, I know I'm not using the API correctly. I'm not sending the data it wants in the correct format or method. What I'm hoping someone can help with is how I should be sending the call based on the operation pages. It looks like it's just expecting a data field which I tried. I also tried sending it in as "parameters" because a lot of sites said that was how it was done.

Is there any way to tell, from the WSDL or Operation pages what it's expecting me to send?


Travis Hawkins
jobs.bestcodingpractices.com
 
nope. if you don't have the information already, you need to ask the site owners for their API specification.
 
ah for crying out loud... they gave me an XML snippet of what to send... if I try to send that it fails. If I try to convert the values from that into an array and send them as an array it fails. I've setup this exact API with .Net and it's simple. I really like PHP... sometimes, this isn't one of those times.

Travis Hawkins
jobs.bestcodingpractices.com
 
post a sample of the .Net code and what they tell you to send in xml. php is just a tool. it will do what you tell it to do and is usually very intuitive.
 
yeah, php is a tool, I feel like I've got my hammer backwards and I'm beating it against my head :)

Here is how it works in .NET:

Code:
Dim webService As New com.travelguard.websvcs.tg_us.TravelGuardUSWebServices 
returnData = webService.GetQuote(sendString)
' sendString holds the xml posted below.

And... the XML
Code:
<?xml version="1.0" encoding="utf-16"?>
<PolicySpecification xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL]
    xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
    <Policy>
        <Product>
            <PlanId>65543</PlanId>
            <ProductCode>008180</ProductCode>
            <OptionalPackages/>
        </Product>
        <Travelers>
            <Traveler>
                <TripCost>1000</TripCost>
                <BirthDate>03/23/1978</BirthDate>
                <Gender>Male</Gender>
                <TravelerName>
                    <First>test</First>
                    <Last>test</Last>
                </TravelerName>
                <Address>
                    <Country>united states of america</Country>
                    <State>wisconsin</State>
                    <City>wausau</City>
                    <Street>qa test streeet</Street>
                    <Zip>55555</Zip>
                </Address>
                <Phone>
                    <Home>111-111-1111</Home>
                </Phone>
                <Beneficiary>
                    <Gender>Female</Gender>
                    <BeneficiaryName>
                        <First>qa</First>
                        <Last>test</Last>
                    </BeneficiaryName>
                </Beneficiary>
                <OptionalPackages/>
                <PromotionalPackages/>
            </Traveler>
        </Travelers>
        <Trip>
            <DepartureDate>05/15/2009</DepartureDate>
            <ReturnDate>05/17/2009</ReturnDate>
            <InitialTripDepositDate>05/12/2009</InitialTripDepositDate>
            <FinalPaymentDate>05/12/2009</FinalPaymentDate>
            <Destinations/>
            <Carriers/>
        </Trip>
        <Fulfillment>
            <NeedEmail/>
        </Fulfillment>
        <MarketingInfo/>
    </Policy>
</PolicySpecification>

There has to be an easy way to just send the XML to the SOAP server without all this messyness?

Thanks a ton for all the help

Travis Hawkins
jobs.bestcodingpractices.com
 
i think you're misusing the methods a bit.

try this instead
Code:
$wsdl = '[URL unfurl="true"]http://staging.tgpolicywebsvcs.travelguard.com/tgpolicyservice.asmx?WSDL';[/URL]
$soap = new soapClient($wsdl);
$return = $soap->GetQuote(array('xml'=>$x, 'encoding'=>'utf-16'));

but i suspect the fastest route to success would be to get the api specification from the SOAP host.
 
>$returnValue = $SC->__soapCall('getQuoteXML', array('parameters' => $getQuote));
Either
[tt]$returnValue=$client->__soapCall('getQuoteXML',array('parameters'=>array([red]'data'[/red]=>$getQuote)));[/tt]
or
[tt]$returnValue = $SC->getQuoteXML(array([red]'data'[/red]=>$getQuote));[/tt]
 
The reference on the first line is $SC per op's notation, my typos.
[tt]
$returnValue=$[red]SC[/red]->__soapCall('getQuoteXML',array('parameters'=>array('[red]data[/red]'=>$getQuote)));[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top