【问题标题】:gSOAP does not return information from web service, but it returns only schemagSOAP 不从 Web 服务返回信息,但它只返回模式
【发布时间】:2011-06-14 16:20:43
【问题描述】:

我正在尝试从 Microsoft Project Server Project Web 服务中检索项目信息。

我使用 gSOAP 来实现客户端。这是我的代码的样子:

if ( project.ReadProjectStatus(&read_project_status_message, &read_project_status_response) == SOAP_OK )
{
    ofstream project_info("C:\\PROJECTINFO.XML");   
    project_info << read_project_status_response.ReadProjectStatusResult->__any;
}

虽然来自项目服务器的响应看起来像:

<soap:Envelope ...>
    <soap:Body ...>
        <ReadProjectStatusResponse ...>
            <ReadProjectStatusResult>
                <xs:schema ...>
                ...
                </xs:schema ...>
                <diffgr:diffgram ...>
                    <ProjectDataSet ...>
                    ....
                    </ProjectDataSet>
                </diffgr:diffgram>
            </ReadProjectStatusResult>
        </ReadProjectStatusResponse>
    </soap:Body>
</soap:Envelope>                   

当我打开文件 PROJECTINFO.XML(其中写入了 read_project_status_response.ReadProjectStatusResult->__any)时,我只能看到

<xs:schema ...>
    ...
</xs:schema> 

部分。没有关于项目信息。

任何人都知道为什么会发生这种情况以及如何使用 gsoap 检索项目状态信息?

提前致谢。

【问题讨论】:

    标签: web-services soap gsoap project-server


    【解决方案1】:

    为时已晚,但这里……

    项目服务器提供的wsdl不完整。看起来像这样。

      <s:element name="ReadProjectStatusResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="ReadProjectStatusResult">
              <s:complexType>
                <s:sequence>
                  <s:any namespace="http://schemas.microsoft.com/office/project/server/webservices/ProjectDataSet/" />
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>
    

    将其更改为以下内容(注意 s:any 之前的额外 s:element)并使用 gsoap 重新编译。现在 gsoap 将创建 2 个成员变量(xsd__schema 和 __any)。 xsd__schema 将包含架构,而 __any 将携带正确的数据。

      <s:element name="ReadProjectStatusResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="ReadProjectStatusResult">
              <s:complexType>
                <s:sequence>
                  <s:element ref="s:schema"/>
                  <s:any namespace="http://schemas.microsoft.com/office/project/server/webservices/ProjectDataSet/" />
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>
    

    【讨论】:

      猜你喜欢
      • 2011-08-11
      • 1970-01-01
      • 1970-01-01
      • 2012-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-30
      相关资源
      最近更新 更多