beanymanuk Posted February 21, 2013 Share Posted February 21, 2013 WSDL <wsdl:definitions targetNamespace="BLANKED"><wsdl:types><s:schema elementFormDefault="qualified" targetNamespace="BLANKED"><s:element name="GetPlatformByUserAgent"><s:complexType><s:sequence><s:element minOccurs="0" maxOccurs="1" name="pUserAgent" type="s:string"/></s:sequence></s:complexType></s:element><s:element name="GetPlatformByUserAgentResponse"><s:complexType><s:sequence><s:element minOccurs="0" maxOccurs="1" name="GetPlatformByUserAgentResult" type="s:string"/></s:sequence></s:complexType></s:element></s:schema></wsdl:types><wsdl:message name="GetPlatformByUserAgentSoapIn"><wsdl:part name="parameters" element="tns:GetPlatformByUserAgent"/></wsdl:message><wsdl:message name="GetPlatformByUserAgentSoapOut"><wsdl:part name="parameters" element="tns:GetPlatformByUserAgentResponse"/></wsdl:message><wsdl:portType name="WebSiteServicesSoap"><wsdl:operation name="GetPlatformByUserAgent"><wsdl:input message="tns:GetPlatformByUserAgentSoapIn"/><wsdl:output message="tns:GetPlatformByUserAgentSoapOut"/></wsdl:operation></wsdl:portType><wsdl:binding name="WebSiteServicesSoap" type="tns:WebSiteServicesSoap"><soap:binding transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="GetPlatformByUserAgent"><soap:operation soapAction="http://BLANK/GetPlatformByUserAgent" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:binding name="WebSiteServicesSoap12" type="tns:WebSiteServicesSoap"><soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="GetPlatformByUserAgent"><soap12:operation soapAction="http://BLANK/GetPlatformByUserAgent" style="document"/><wsdl:input><soap12:body use="literal"/></wsdl:input><wsdl:output><soap12:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="WebSiteServices"><wsdl:port name="WebSiteServicesSoap" binding="tns:WebSiteServicesSoap"><soap:address location="http://BLANK/WebSiteServices.asmx"/></wsdl:port><wsdl:port name="WebSiteServicesSoap12" binding="tns:WebSiteServicesSoap12"><soap12:address location="http://BLANK/WebSiteServices.asmx"/></wsdl:port></wsdl:service></wsdl:definitions> Code I am using <?php class GetPlatformByUserAgent{ public $useragent = 1234 ; //$a = $_SERVER['HTTP_USER_AGENT']; }; $client = new SoapClient("http://BLANK.asmx?wsdl"); $response = $client->GetPlatformByUserAgent("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"); echo $response ?> Error I get ( ! ) Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in C:\wamp\websites\projects\soap\test.php:7 Stack trace: #0 C:\wamp\websites\projects\soap\test.php(7): SoapClient->__call('GetPlatformByUs...', Array) #1 C:\wamp\websites\projects\soap\test.php(7): SoapClient->GetPlatformByUserAgent('Mozilla/4.0 (co...') #2 {main} thrown in C:\wamp\websites\projects\soap\test.php on line 7 Any ideas where I am going wrong as I'm new to SOAP calls? Quote Link to comment https://forums.phpfreaks.com/topic/274768-php-soap-call/ Share on other sites More sharing options...
StevenFullman Posted February 21, 2013 Share Posted February 21, 2013 (edited) Hi there, You need to pass in the name of the parameter (as an array) as well: <?php class GetPlatformByUserAgent{ public $useragent = 1234 ; //$a = $_SERVER['HTTP_USER_AGENT']; }; $client = new SoapClient("[url="http://BLANK.asmx?wsdl"]http://BLANK.asmx?wsdl"[/url]); $response = $client->GetPlatformByUserAgent(array("pUserAgent" => "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")); echo $response ?> Cheers, Steve Edited February 21, 2013 by StevenFullman Quote Link to comment https://forums.phpfreaks.com/topic/274768-php-soap-call/#findComment-1413900 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.