0

我有一个 c++ 应用程序,并试图使用它通过 Windows Web 服务 API 联系 UPS Web 服务。UPS 提供了一些 C# 编程示例,我已经将最简单的示例(LabelRecovery - 从 Web 服务读取标签)翻译成 C++。

C# 程序在下载时可以正常工作。运行我翻译的c++版本时,遇到错误:

Failure: errorCode=0x803d0000
There was an error communicating with the endpoint at 'https://wwwcie.ups.com/webservices/LBRecovery'.
The content type 'text/xml' did not match the expected value 'application/soap+xml'.

也许我缺少一个内容类型设置,我尝试根据其他研究文章修改各种 CHANNEL 和 PROXY 设置但没有成功。因此,如果您仅从上面的描述中知道我缺少什么,那么您可以在此处停止阅读,请让我知道如何继续。

我不确定的程序的一个方面是尝试附加消息的 UPSSecurity 部分,它会通知 UPS 用户/密码......我从不主动将 UPSSecurity 结构链接到消息,但它可能是隐式链接的,并且我只是没有看到它。

Windows Web 服务 (WWS) 使用名为“wsutil.exe”的程序将 UPS 提供的 Web 服务描述文件(wsdl、xsd...)转换为绑定,WWS API 将使用这些绑定来创建要通信的消息。LabelRecovery 定义文件 (wsdl) 使用以下部分来描述 LabelRecoveryRequest 消息:

  <wsdl:message name="LabelRecoveryRequestMessage">
    <wsdl:part name="Body" element="lbrec:LabelRecoveryRequest" />
    <wsdl:part name="UPSSecurity" element="upss:UPSSecurity" />
  </wsdl:message>

这个定义使它看起来像“UPSSecurity”是LabelRecovery Request消息的一部分。但我找不到可以链接我的 UPSSecurity 信息的可寻址参考。wsutil.exe 实用程序生成的“c”代码仅在注释中引用“UPSSecurity”:

// Fault Message LabelRecoveryWS_wsdl.faults.LabelRecoveryWS_wsdl_LabelRecoveryErrorMessage,
    // Fault Action 
    // fault message Error1_1_xsd_Errors
//  input message soap header element is
//(WS_ELEMENT_DESCRIPTION*)&UPSSecurity_xsd.globalElements.UPSSecurity_xsd_UPSSecurity, 
//input message soap headerfault element is
//(WS_ELEMENT_DESCRIPTION*)&Error1_1_xsd.globalElements.Error1_1_xsd_Errors, 
// operation: LabelRecoveryWS_wsdl_LabelRecoveryBinding_ProcessLabelRecovery
HRESULT WINAPI LabelRecoveryWS_wsdl_LabelRecoveryBinding_ProcessLabelRecovery(
    _In_ WS_SERVICE_PROXY* _serviceProxy,
    _In_ _LBRecovery_xsd_LabelRecoveryRequest* LabelRecoveryWS_wsdl_Body, 
    _Outptr_ _LBRecovery_xsd_LabelRecoveryResponse** outLabelRecoveryWS_wsdl_Body, 
    _In_ WS_HEAP* _heap,
    _In_reads_opt_(_callPropertyCount) const WS_CALL_PROPERTY* _callProperties,
    _In_ const ULONG _callPropertyCount,
    _In_opt_ const WS_ASYNC_CONTEXT* _asyncContext,
    _In_opt_ WS_ERROR* _error)
{
    void* _argList[2]; 
    _argList[0] = &LabelRecoveryWS_wsdl_Body;
    _argList[1] = &outLabelRecoveryWS_wsdl_Body;
    return WsCall(_serviceProxy,
        (WS_OPERATION_DESCRIPTION*)&LabelRecoveryWS_wsdlLocalDefinitions.contracts.LabelRecoveryWS_wsdl_LabelRecoveryBinding.LabelRecoveryWS_wsdl_LabelRecoveryBinding_ProcessLabelRecovery.LabelRecoveryWS_wsdl_LabelRecoveryBinding_ProcessLabelRecovery,
        (const void **)&_argList,
        _heap,
        _callProperties,
        _callPropertyCount,
        _asyncContext,
        _error);
}

具体来说,//(WS_ELEMENT_DESCRIPTION*)&UPSSecurity_xsd.globalElements.UPSSecurity_xsd_UPSSecurity,。该评论似乎推断这应该作为 SOAP 标头而不是作为 LabelRecoveryRequest 消息的一部分放置,但我无法就如何处理我的 UPSSecurity 结构、SOAP 标头或其他方式建立联系。我希望你们中的一个聪明人之前已经遇到过这个问题,并且会得到完美的回应。

提供整套代码会很长,所以我希望我的摘录能显示足够的细节,至少可以开始讨论。如果有帮助,我正在编写基于 Windows Web 服务 API 的“服务模型”。

预先感谢您的协助。

(我在 Visual Studio 17 中构建它,并在最新更新的 Windows 10 21H1 上运行。)

4

0 回答 0