如何添加soap header来反应原生?

问题描述 投票:0回答:1

我在c#中使用soap标头,如下所示:

MeyerWebService.WebServiceEmployees tasnifWS = new MeyerWebService.WebServiceEmployees();
        tasnifWS.UserDetailsValue = new UserDetails()
        {
            userName = "**",
            password = "**"
        };

但我不知道如何在本地反应中做到这一点

c# react-native
1个回答
1
投票

您可以使用一个简单的模块通过WSSecurity发出SOAP请求

npm install react-native-soap-request --save

const soapRequest = new SoapRequest({
  security: {
    username: 'username',
    password: 'password'
  },
  targetNamespace: 'http://soap.acme.com/2.0/soap-access-services',
  commonTypes: 'http://soap.acme.com/2.0/soap-common-types',
  requestURL: soapWebserviceURL
});

const xmlRequest = soapRequest.createRequest({
  'soap:ProductRegistrationRequest': {
    attributes: {
      'xmlns:soap': 'http://soap.acme.com/2.0/soap-access-services',
      'xmlns:cmn': 'http://soap.acme.com/2.0/soap-common-types'
    },
    'soap:productId': {
      'cmn:internalId': {
        'cmn:id': productId
      }
    },
    'soap:userId': {
      'cmn:internalId': {
        'cmn:id': userId
      }
    }
  }
});

const response = await soapRequest.sendRequest();
© www.soinside.com 2019 - 2024. All rights reserved.