【问题标题】:Call soap web-service in mobilefirst hybrid app在 mobilefirst 混合应用程序中调用肥皂网络服务
【发布时间】:2015-08-10 19:02:44
【问题描述】:

我正在尝试在混合应用程序中调用 SOAP Web 服务。如果后端服务在日志中显示下一个错误,我应该如何正确形成 SOAP 消息:

原因:com.ibm.websphere.security.WSSecurityException:异常 org.apache.axis2.AxisFault: CWWSS7509W: 收到的 SOAP 请求 消息被拒绝,因为它没有正确指定 SOAP 操作 和 WS-Addressing 操作,同时至少有一个 PolicySet 在操作级别的附件 TestServiceService.TestServicePort 服务。运行时发生 行动: com.ibm.ws.wssecurity.handler.WSSecurityConsumerHandler$1@9b5addf6 在 com.ibm.ws.security.context.ContextImpl.runWith(ContextImpl.java:394) 在 com.ibm.ws.wssecurity.platform.websphere.auth.WSSContextImpl.runWith(WSSContextImpl.java:65) ... 35 更多

这是适配器中js文件的内容

function getToken(){
var token = WL.Server.getActiveUser().attributes.LtpaToken;
var fulltoken = "LtpaToken2=" + token;

return fulltoken;
    }

function callService(){
WL.Logger.warn("INSIDE callService "+getToken());
var path="checkauth/TestServiceService";
    var request= 
        <soapenv:Envelope 
        xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:q0="http://provider.ws/" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
  <q0:callService /> 
  </soapenv:Body>
  </soapenv:Envelope>;
  var input = {
            method : 'post',
            returnedContentType : 'xml',
            path : path,
            body: {
                content: request.toString(),
                contentType: 'text/xml; charset=utf-8',
                },
             headers: {"Cookie": getToken()}
        };

        var result= WL.Server.invokeHttp(input);
        return result;
    }

这是通过 TCP/IP 监视器显示的 SOAP 信封:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<s:Security xmlns:s="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:w2="http://www.ibm.com/websphere/appserver/tokentype" soapenv:mustUnderstand="1">
    <u:Timestamp>
    <u:Created>2015-08-10T13:18:56.644Z</u:Created>
    </u:Timestamp>
    <s:BinarySecurityToken ValueType="w2:LTPAv2" u:Id="ltpa_20">dt8G5gZ9PpZ/Ea5oXr6EQd8dpmfXKiqeXiShPlpSWntK59hUzyoDNX9TKq1nFLfxUEJyJdjMxoG7EVxw8Q1zhyZdYhTXnsMkNVqScvSsPpX7ln/ad+/WAHqaaFymD8XtVEsjOlezQDarPaUmnKAQRUSrLkRnL5B1MoCclTe129Oojg8o+hACgDKjuvPnvL8jaf45wNiou6Il5ZOayBcoHpNehI7i2hADa4fTKzX/T69OPnsZOyWYrNosdezNd24b61vs85k2YK26rLTp5dkEp8f3mwKZBwOOK4z1wQdiAXJf6kQvzR22SfFitbJA5MStlBcovHAvB5T+J5Ip80/kI5BPa2ogoufd9HZAdKTNII8cHpHBN2Ub/+atzg1L7EhIWuzO1BPI62KoU/hPqAHn3uGCGrbIILesKx0TPvlgmU4Bg54H9prC0I8hgXbO1HLuz4M5DNE5ASFbH0W3LJ/UU7BGXJs6iJmfAfJtQ+ip5ZFHlLItZA+ca2LkVWmyD/xKVxyxHE1uDz8zV/CfV9Km0T+8FTA0Cfi/PIb5KiAagdrmqtw6GuJDbSCsC3sdh21G/cA3Y0p/f+rhDw8m/e17y1cEuq9HOBharwn7ET3wO30V4D4rGoLhd4QsN6X1z89gZmZVaI6J9urpPAEiSndmyQ==</s:BinarySecurityToken>
</s:Security>
    <wsa:To>http://X.X.X.X:9082/checkauth/TestServiceService</wsa:To>
    <wsa:MessageID>urn:uuid:5d1f8656-5550-40d2-9f39-c58f57279489</wsa:MessageID>
    <wsa:Action>http://provider.ws/TestServiceDelegate/callServiceRequest</wsa:Action>
</soapenv:Header>
<soapenv:Body>
    <ns2:callService xmlns:ns2="http://provider.ws/"/>
</soapenv:Body></soapenv:Envelope>

【问题讨论】:

    标签: soap ibm-mobilefirst mobilefirst-adapters


    【解决方案1】:

    body 由单行组成,这使得场景变得奇特,并提出了一个问题,这是否真的有效。

    我可以建议两件事:

    1. 您可以尝试使用 SOAPUI 应用程序解析您的 WSDL 文件;它应该向您展示 SOAP 信封的外观

    2. 使用 MobileFirst Studio 中的服务发现功能,该功能可以为您生成带有现成 SOAP 信封的适配器。在此处阅读更多如何使用此功能:http://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.dev.doc/dev/c_using_service_discovery_wizard_to_explore_backend-services.html

    【讨论】:

    • 我尝试使用你的两个建议@Idan,每个案例都显示了我在上面粘贴的相同日志消息。 TCP/IP Monitor 显示我需要形成的下一个肥皂信封。我将它添加到我的第一篇文章中。你能推荐我能做些什么来调用安全的肥皂网络服务吗?我没有找到关于如何在 mobilefirst 中调用安全肥皂网络服务的信息
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-29
    • 2021-07-29
    • 2017-01-16
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多