Результат SOAP Webservice возвращает 500 код ошибки - PullRequest
0 голосов
/ 04 июля 2019

Я использовал SOAP Webservice через Nodejs:

$(document).ready(function() {

    $.ajax({
            url: "/track/vehicule/getWebserviceRetourKYC",
            type: "POST",
            success : function(data, status, xhr) {
              console.dir(data);
            },
            error : function(xhr, status, error) {
              console.dir(error);
            }
          });

  });

var express = require('express');
var request = require("request");
var fs = require('fs');
var path = require('path');
var async = require('async');
var router = express.Router();
var db = require('./db');
var utils = require('./utils');
var connexion = db.getConnexion();

router.post("/getWebserviceRetourKYC", function(req, res) {
    var soap = require('strong-soap').soap;
    // wsdl of the web service this client is going to invoke. For local wsdl you can use, url = './wsdls/stockquote.wsdl'
    var url = "https://www.telma.net/sentimsa/mvola/wsdl.php?module=jWSDL&action=WSDL:wsdl&service=mvola~WSMVolaGetInfosKYC";

    var requestArgs = {
        module:'jWSDL',
        action:'WSDL:wsdl',
        service:'mvola~WSMVolaGetInfosKYC'
    };

    var options = {};
    soap.createClient(url, options, function(err, client) {
        var method = client['WSMVolaGetInfosKYCCtrl']['WSMVolaGetInfosKYCCtrlPort']['getInfosKYC'];
        console.dir(client);//here
        method(requestArgs, function(err, result, envelope, soapHeader) {
            //response envelope
            console.log('Response Envelope: \n' + envelope);
            //'result' is the response body
            console.log('Result: \n' + JSON.stringify(result));
        });
    });
    res.send();
});

module.exports = router;

Во время выполнения возвращаемый результат:

{
    "statusCode": 500,
    "body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client<\/faultcode><faultstring>Error cannot find parameter<\/faultstring><\/SOAP-ENV:Fault><\/SOAP-ENV:Body><\/SOAP-ENV:Envelope>\n",
    "headers": 
    {
        "date": "Thu, 04 Jul 2019 05:51:26 GMT",
        "server": "Apache/2.2.3 (Red Hat)",
        "content-length": "294",
        "content-type": "text/xml; charset=utf-8",
        "content-language": "en",
        "connection": "close"
    },
    "request": 
    {
        "uri": 
        {
            "protocol": "https:",
            "slashes": true,
            "auth": null,
            "host": "www.telma.net",
            "port": 443,
            "hostname": "www.telma.net",
            "hash": null,
            "search": "?service=mvola%7EWSMVolaGetInfosKYC",
            "query": "service=mvola%7EWSMVolaGetInfosKYC",
            "pathname": "/sentimsa/mvola/soap.php",
            "path": "/sentimsa/mvola/soap.php?service=mvola%7EWSMVolaGetInfosKYC",
            "href": "https://www.telma.net/sentimsa/mvola/soap.php?service=mvola%7EWSMVolaGetInfosKYC"
        },
        "method": "POST",
        "headers": 
        {
            "User-Agent": "strong-soap/1.20.0",
            "Accept": "text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8",
            "Accept-Encoding": "none",
            "Accept-Charset": "utf-8",
            "Connection": "close",
            "Host": "www.telma.net",
            "Content-Length": 396,
            "Content-Type": "text/xml; charset=utf-8",
            "SOAPAction": "\"https://www.telma.net/sentimsa/mvola/soap.php?service=mvola%7EWSMVolaGetInfosKYC&method=getInfosKYC\""
        }
    }
}

Так что не так в моих кодах?

------ изменить ------:

Вот пример конверта и желаемого результата:

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mvol="https://www.telma.net/sentimsa/mvola/">

   <soapenv:Header/>

   <soapenv:Body>

      <mvol:getInfosKYC soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

         <zSubscriberId xsi:type="xsd:string"> 0340017729</zSubscriberId>

      </mvol:getInfosKYC>

   </soapenv:Body>

</soapenv:Envelope>

Ответ:

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://www.telma.net/sentimsa/mvola/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">

   <SOAP-ENV:Body>

      <ns1:getInfosKYCResponse>

         <getInfosKYCReturn xsi:type="ns1:CCodeReponse">

            <oDataKYC xsi:nil="true" xsi:type="ns1:CKycInfos"/>

            <status_Code xsi:type="xsd:string">101</status_Code>

            <status_Reason xsi:type="xsd:string">Le numéro 0340017728 n’existe pas dans Sentinel.</status_Reason>

         </getInfosKYCReturn>

      </ns1:getInfosKYCResponse>

   </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

1 Ответ

0 голосов
/ 04 июля 2019

Ошибка:

<faultstring>Error cannot find parameter<\/faultstring>

Предполагается, что в вашем запросе отсутствует обязательный параметр. У вас есть документация для сервиса SOAP, который вы используете? module, action и service являются единственными обязательными параметрами?

Кроме того, вы также включили эти параметры в строку URL:

var url = "https://www.telma.net/sentimsa/mvola/wsdl.php?module=jWSDL&action=WSDL:wsdl&service=mvola~WSMVolaGetInfosKYC";

Не уверен, если это вызовет проблемы, но, по крайней мере, это не должно требоваться. Я бы попытался удалить эти параметры из строки URL.

...