Answer the question
In order to leave comments, you need to log in
Why is there an error in soap request 'not valid method'?
Good afternoon. The question may seem childish to people who work closely with web services, but I'm in the process of learning and decided to understand the basic principles of working with SOAP through php.
here is the full content of the error: Fatal error: Uncaught SoapFault exception: [Client] Function ("getStock") is not a valid method for this service in E:\servNew\OSPanel\domains\test-soap\index.php on line 8
here my server:
<?php
function getStock($id) {
$stock = [
'1' => 100,
'2' => 200,
'3' => 300,
'4' => 400,
];
$quantity = $stock[$id];
return $quantity;
}
ini_set('soap.wsdl_cache_enabled', '0');
$server = new SoapServer( 'test.wsdl' );
$server->addFunction('getStock');
$server->handle();
?>
<?php
$client = new
SoapClient(
"test.wsdl"
);
$client->getStock('1');
?>
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='Stock'
targetNamespace='http://example.org/StockQuote'
xmlns:tns=' http://example.org/StockQuote '
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<message name='getStockRequest'>
<part name='id' type='xsd:string'/>
</message>
<message name='getStockResponse'>
<part name='Result' type='xsd:integer'/>
</message>
<portType name='StockPortType'>
<operation name='getStock'>
<input message='tns:getStockRequest'/>
<output message='tns:getStockResponse'/>
<operation>
<portType>
<binding name='StockBinding' type='tns:StockPortType'>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='getStock' />
<binding>
<service name='StockService'>
<port name='StockPort' binding='StockBinding'>
<soap:address location='test.wsdl'/>
<port>
</service>
</definitions>
Answer the question
In order to leave comments, you need to log in
A SoapFault exception will be thrown if the wsdl URI cannot be loaded.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question