【发布时间】:2017-09-08 16:12:59
【问题描述】:
网络服务
如何在 Swift 中连接使用 WS-Security 和发送 HttpBody 数据的 Web 服务。 ?
我试试这个How to make an HTTP request + basic auth in Swift
我使用这个库https://github.com/priore/SOAPEngine
let soap = SOAPEngine()
soap.licenseKey = "12324351242345xxss3ews"
soap.actionNamespaceSlash = true
soap.authorizationMethod = SOAPAuthorization.AUTH_WSSECURITY_TEXT
soap.username = "user"
soap.password = "test.password"
soap.envelope = "<soapenv:Envelope xmlns:com1='http://www.rbm.com.co/esb/comercio/' xmlns:esb='http://www.rbm.com.co/esb/' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:com='http://www.rbm.com.co/esb/comercio/compra/'><soapenv:Header /><soapenv:Body> <com:compraProcesarSolicitud><com:cabeceraSolicitud><com:infoPuntoInteraccion><com1:tipoTerminal>WEB</com1:tipoTerminal><com1:idTerminal>ESB10434</com1:idTerminal><com1:idAdquiriente>0010203040</com1:idAdquiriente> <com1:idTransaccionTerminal>789654</com1:idTransaccionTerminal><com1:modoCapturaPAN>Manual</com1:modoCapturaPAN><com1:capacidadPIN>Virtual</com1:capacidadPIN></com:infoPuntoInteraccion></com:cabeceraSolicitud><com:idPersona><esb:tipoDocumento>CC</esb:tipoDocumento><esb:numDocumento>123456789</esb:numDocumento></com:idPersona><com:infoMedioPago><com:idTarjetaCredito><esb:franquicia>MasterCard</esb:franquicia><esb:numTarjeta>5303710409428783</esb:numTarjeta><esb:fechaExpiracion>2019-03-30</esb:fechaExpiracion><esb:codVerificacion>742</esb:codVerificacion></com:idTarjetaCredito></com:infoMedioPago><com:infoCompra><com:montoTotal>22222.00</com:montoTotal><com:infoImpuestos><esb:tipoImpuesto>Consumo</esb:tipoImpuesto><esb:monto>3065.00</esb:monto><esb:baseImpuesto>19157.00</esb:baseImpuesto></com:infoImpuestos> <com:montoDetallado><esb:tipoMontoDetallado>BaseDevolucionIVA</esb:tipoMontoDetallado><esb:monto>19157.00</esb:monto></com:montoDetallado><com:referencia>Frisby App iOS</com:referencia><com:cantidadCuotas>1</com:cantidadCuotas></com:infoCompra></com:compraProcesarSolicitud></soapenv:Body></soapenv:Envelope>"
soap.requestURL("https://www.123345.com/test/",
soapAction: "action",
completeWithDictionary: { (statusCode: Int?, dict: [AnyHashable: Any]?) -> Void in
print("\(String(describing: dict))")
}) { (error: Error?) -> Void in
print(error!)
}
服务器在第 2 行返回此“非法字符 '
【问题讨论】:
-
您是否真的对该主题进行过任何研究?到目前为止你尝试了什么?什么不工作?
-
是的,我试试这个示例stackoverflow.com/questions/24379601/…
-
然后在您的问题中包含实际代码并解释它是如何不起作用的......
-
请稍等片刻
-
请不要发布任何机密信息,例如 licenseKey。为了您的安全,请删除它
标签: ios swift soap ws-security wss