我最近开始使用 symfony 进行开发。我只是简单地创建了一个肥皂服务器。
这是我的代码。
config.yml - 服务器
be_simple_soap:
services:
Gremios:
namespace: http://att/app_dev.php/ws/Gremios
binding: rpc-literal
resource: "@attBundle/Controller/GremioController.php"
resource_type: annotation
Gremios 控制器
class GremioController extends Controller{
/**
* @Route("/apiGremio/{id}")
* @Method("GET")
* @Soap\Method("getGremio")
* @Soap\Param("name", phpType = "int")
* @Soap\Result(phpType = "att\Bundle\Entity\Atgremio")
*/
public function apiGremioAction($id)
{
$gremio = $this->getDoctrine()->getRepository("attBundle:Atgremio")
->findById($id);
return $gremio;
}
}
实体攻击
namespace att\Bundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
/**
* Atgremio
*
* @ORM\Table(name="AtGremio")
* @ORM\Entity
* @Soap\Alias("Gremio")
*/
class Atgremio
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @Soap\ComplexType("int", nillable=true)
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="desGremio", type="string", length=50, nullable=false)
* @Soap\ComplexType("string")
*/
private $desgremio;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set desgremio
*
* @param string $desgremio
* @return Atgremio
*/
public function setDesgremio($desgremio)
{
$this->desgremio = $desgremio;
return $this;
}
/**
* Get desgremio
*
* @return string
*/
public function getDesgremio()
{
return $this->desgremio;
}
}
config.yml 客户端
be_simple_soap:
clients:
GremioApi:
wsdl: "http://att/app_dev.php/ws/Gremios?wsdl"
控制器中的客户端操作
class PruebaController extends Controller
{
/**
* @Route("/gremioapp/{id}")
* @Template
*/
public function pruebaControllerAction($id)
{
$client = $this->container->get('besimple.soap.client.gremioapi');
$result = $client->getGremio($id);
return $result;
}
}
当我执行客户端操作时,我收到错误 500。但是,当执行服务器操作时,没有发现错误。当我看到生成的 wdsl 时相等
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://att/app_dev.php/ws/Gremios" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Gremios" targetNamespace="http://att/app_dev.php/ws/Gremios">
<portType name="GremiosPortType">
<operation name="getGremio">
<input message="tns:getGremioRequest"/>
<output message="tns:getGremioResponse"/>
</operation>
</portType>
<types>
<xsd:schema targetNamespace="http://att/app_dev.php/ws/Gremios">
<xsd:complexType name="Gremio">
<xsd:all>
<xsd:element name="id" type="xsd:int" nillable="true"/>
<xsd:element name="desgremio" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
</types>
<message name="getGremioRequest">
<part name="name" type="xsd:int"/>
</message>
<message name="getGremioResponse">
<part name="return" type="tns:Gremio"/>
</message>
<service name="GremiosService">
<port name="GremiosPort" binding="tns:GremiosBinding">
<soap:address location="http://localhost:5080/app_dev.php/ws/Gremios"/>
</port>
</service>
<binding name="GremiosBinding" type="tns:GremiosPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="getGremio">
<soap:operation soapAction="http://att/app_dev.php/ws/GremiosgetGremio"/>
<input>
<soap:body use="literal" namespace="http://att/app_dev.php/ws/Gremios" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="literal" namespace="http://att/app_dev.php/ws/Gremios" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
</definitions>
坦克寻求帮助