|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-08-30 17:26 UTC] mattsch at gmail dot com
Description:
------------
I would like to see the ability for SCA to not parse public functions that don't have PHPDocumentor-style annotations. Currently I'm forced to extend the component class in php just so the public functions I want to use within php are not also available in the wsdl.
Reproduce code:
---------------
<?php
include "SCA/SCA.php";
/**
* Scaffold implementation for a remote StockQuote Web service.
*
* @service
* @binding.soap
*
*/
class StockQuote {
/**
* Get a stock quote for a given ticker symbol.
*
* @param string $ticker The ticker symbol.
* @return float The stock quote.
*/
function getQuote($ticker) {
return 80.9;
}
function foo($bar){
return $bar;
}
}
?>
Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns2="http://stockquote" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://stockquote">
<types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://stockquote"
elementFormDefault="qualified">
<xs:element name="getQuote">
<xs:complexType>
<xs:sequence>
<xs:element name="ticker" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getQuoteResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="getQuoteReturn" type="xs:float"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</types>
<wsdl:message name="getQuoteRequest">
<wsdl:part name="getQuoteRequest" element="tns2:getQuote"/>
</wsdl:message>
<wsdl:message name="getQuoteResponse">
<wsdl:part name="return" element="tns2:getQuoteResponse"/>
</wsdl:message>
<wsdl:portType name="stockquotePortType">
<wsdl:operation name="getQuote">
<wsdl:input message="tns2:getQuoteRequest"/>
<wsdl:output message="tns2:getQuoteResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="stockquoteBinding" type="tns2:stockquotePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="getQuote">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="stockquoteService">
<wsdl:port name="stockquotePort" binding="tns2:stockquoteBinding">
<soap:address location="http://portal.work/stockquote.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
<!-- this line identifies this file as WSDL generated by SCA for PHP. Do not remove -->
Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns2="http://stockquote" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://stockquote">
<types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://stockquote"
elementFormDefault="qualified">
<xs:element name="getQuote">
<xs:complexType>
<xs:sequence>
<xs:element name="ticker" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getQuoteResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="getQuoteReturn" type="xs:float"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="foo">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="fooResponse">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</types>
<wsdl:message name="getQuoteRequest">
<wsdl:part name="getQuoteRequest" element="tns2:getQuote"/>
</wsdl:message>
<wsdl:message name="getQuoteResponse">
<wsdl:part name="return" element="tns2:getQuoteResponse"/>
</wsdl:message>
<wsdl:message name="fooRequest">
<wsdl:part name="fooRequest" element="tns2:foo"/>
</wsdl:message>
<wsdl:message name="fooResponse">
<wsdl:part name="return" element="tns2:fooResponse"/>
</wsdl:message>
<wsdl:portType name="stockquotePortType">
<wsdl:operation name="getQuote">
<wsdl:input message="tns2:getQuoteRequest"/>
<wsdl:output message="tns2:getQuoteResponse"/>
</wsdl:operation>
<wsdl:operation name="foo">
<wsdl:input message="tns2:fooRequest"/>
<wsdl:output message="tns2:fooResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="stockquoteBinding" type="tns2:stockquotePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="getQuote">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="foo">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="stockquoteService">
<wsdl:port name="stockquotePort" binding="tns2:stockquoteBinding">
<soap:address location="http://portal.work/stockquote.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
<!-- this line identifies this file as WSDL generated by SCA for PHP. Do not remove -->
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 19:00:01 2025 UTC |
Apparently you guys already had this in mind, so I finished it: --- SCA_AnnotationReader.php.orig 2007-08-30 17:50:40.000000000 -0500 +++ SCA_AnnotationReader.php 2007-08-30 17:51:05.000000000 -0500 @@ -222,13 +222,13 @@ $methodAnnotations = SCA_AnnotationRules::createEmptyAnnotationArray(); $comment = $public_method->getDocComment(); - + $isWebMethod = true; /* When the method has a doc comment .... */ if ( $comment != false ) { $method_reader = new SCA_CommentReader($comment); - + $isWebMethod = $method_reader->isWebMethod(); /* ... and the method a web service method .... */ - if ($method_reader->isWebMethod()) { + if ($isWebMethod) { /* ... decode any method annotations. */ $methodAnnotations = $method_reader->getMethodAnnotations(); @@ -280,7 +280,8 @@ }/* End comment has value */ /* Save the annotation set indexed by the method name. */ - $operations[$public_method->getName()] = $methodAnnotations ; + if ($isWebMethod) + $operations[$public_method->getName()] = $methodAnnotations ; }/* End every method */ --- SCA_CommentReader.php.orig 2007-08-30 17:50:55.000000000 -0500 +++ SCA_CommentReader.php 2007-08-30 17:51:10.000000000 -0500 @@ -417,8 +417,8 @@ public function isWebMethod() { - // currently exposing all methods if the class is a web service - // leave this test in place in case we want to change our mind + if ($this->_hasAnnotation('webmethod') && ! $this->_getBooleanFollowing('webmethod')) + return false; return true; }This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pecl.php.net. In case this was a pecl.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PECL better. The code/unit tests to support this have now been checked into the FULMAR branch. The service operations made available can now be controlled by specifying an interface in the @service annotation (e.g @service MyServiceInterface). Note, because of the different way in which PHP defines standalone classes versus those which extend classes or implement interfaces, the include for SCA.php much come after the service implementation class declaration. For example: <?php require 'MyPrivateInterface.php'; require 'MyServiceInterface.php'; /** * MyService with a nonServiceMethod * @service MyServiceInterface * */ class MyService implements MyServiceInterface, MyPrivateInterface { /** * A method that I don't want to appear * */ public function nonServiceMethod() {} /** * A private method that should not appear * */ private function privateMethod() {} /** * My first service method defined in MyServiceInterface * * @param string $in1 * @return float */ public function serviceMethod1($in1) {} /** * My second service method defined in MyServiceInterface * * @param string $in1 * @param float $in2 * @return integer */ public function serviceMethod2($in1, $in2) {} } include 'SCA/SCA.php'; ?>