salesforce - 未找到元素 : userDetails 的顶点类型

标签 salesforce callouts

我从网络服务收到以下响应

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><GetUserResponse xmlns="urn:wwservice"><userDetails xmlns="">Successfully write a web service hurray</userDetails></GetUserResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

但我得到 Apex type not found for element : userDetails

这是我的 wsdl 文件

<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:wwservice" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:wwservice">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="urn:wwservice">
 <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
 <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
 <xsd:complexType name="GetUserRequestType">
  <xsd:all>
   <xsd:element name="Username" type="xsd:string" form="unqualified"/>
   <xsd:element name="Password" type="xsd:string" form="unqualified"/>
  </xsd:all>
 </xsd:complexType>
 <xsd:complexType name="GetUserResponseType">
  <xsd:all>
   <xsd:element name="userDetails" type="xsd:string" form="unqualified"/>
  </xsd:all>
 </xsd:complexType>
 <xsd:element name="GetUser" type="tns:GetUserRequestType"/>
 <xsd:element name="GetUserResponse" type="tns:GetUserResponseType"/>
</xsd:schema>
</types>
<message name="GetUserRequest">
  <part name="parameters" element="tns:GetUser"/></message>
<message name="GetUserResponse">
  <part name="parameters" element="tns:GetUserResponse"/></message>
<portType name="PsocialPortType">
  <operation name="GetUser">
    <input message="tns:GetUserRequest"/>
    <output message="tns:GetUserResponse"/>
  </operation>
</portType>
<binding name="PsocialBinding" type="tns:PsocialPortType">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
  <operation name="GetUser">
    <soap:operation soapAction="urn:wwservice#GetUser" style="document"/>
    <input><soap:body use="literal" namespace="urn:wwservice"/></input>
    <output><soap:body use="literal" namespace="urn:wwservice"/></output>
  </operation>
</binding>
<service name="Psocial">
  <port name="PsocialPort" binding="tns:PsocialBinding">
    <soap:address location="http://example.com/webservice/wwservice.php"/>
  </port>
</service>
</definitions>

请告诉我哪里出错了

我正在使用它来创建 WSDL

$server = new soap_server();
    // Changed for coupons data start
    $server->soap_defencoding = 'UTF-8';
    $server->decode_utf8 = false;
    // Changed for coupons data end

    //$server->configureWSDL('m-way', 'urn:wwservice');
    $server->configureWSDL('Psocial', 'urn:wwservice',false,'document');


    // New function for spiff
    $server->register("GetUser", 
    array('Username'=>'xsd:string','Password'=>'xsd:string'),
    array('userDetails'=>'xsd:string'),
    'urn:wwservice',
    'urn:wwservice#GetUser', 'document', 'literal'
    );



    $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)? $HTTP_RAW_POST_DATA : file_get_contents('php://input');
    $server->service($HTTP_RAW_POST_DATA);

最佳答案

问题是您获得的 SOAP 响应与 WSDL 中的描述不匹配,WSDL 的模式有 elementFormDefault="qualified",它表示子元素将是在命名空间中,例如它说响应应该是

<GetUserResponse xmlns="urn:wwservice">
   <userDetails>Hello</userDetails>
</GetUserResponse>

但是您得到的实际响应是

<GetUserResponse xmlns="urn:wwservice">
     <userDetails xmlns="">Successfully write a web service hurray</userDetails>
</GetUserResponse>

请注意 userDetails 元素的命名空间有何不同。您应该将 WSDL 更新为 elementForDefault="unqualified",或者更新 Web 服务以在 userDetails 元素上返回正确的命名空间。

关于salesforce - 未找到元素 : userDetails 的顶点类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14890086/

相关文章:

amazon-web-services - AWS AppFlow Salesforce 到 Lambda 不完整事件

salesforce - 在没有包的情况下从开发组织部署到新的不相关组织

iphone - 创建带有按钮的自定义调出 View

ios - 自定义 map 注释标注 - 如何控制宽度

ios - didSelect 自定义 POI 仅在 map 放大时触发

salesforce - 无法通过 twilio 接收短信

javascript - 无法获取 Node 请求以发布到 salesforce 网络潜在客户

salesforce - 对现有数据触发触发器?

iphone - 如何在 map 首次加载时自动打开 map 上的注释标注?

iphone - 发件人时提取 MKAnnotation 标注的标题