簡體   English   中英

如何添加soap header到react-native?

[英]how to add soap header to react-native?

我在c#中使用soap header這樣:

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

但是我不知道如何在本機中做到這一點

您可以使用一個簡單的模塊通過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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM