在mobilefirst混合应用程序中调用soap web-service

时间:2015-08-10 19:02:45

标签: soap ibm-mobilefirst mobilefirst-adapters

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

  

引起:com.ibm.websphere.security.WSSecurityException:异常   org.apache.axis2.AxisFault:CWWSS7509W:收到的SOAP请求   消息被拒绝,因为它没有正确指定SOAP操作   和至少有一个PolicySet时的WS-Addressing操作   在操作层面的附件   TestServiceService.TestServicePort服务。跑步时发现   行动:   com.ibm.ws.wssecurity.handler.WSSecurityConsumerHandler$1@9b5addf6 at   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 Monitor显示的SOAP Envelope:

<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>

1 个答案:

答案 0 :(得分:0)

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