web-services 相关问题

“Web服务”是一种软件系统,旨在通过万维网支持可互操作的机器对机器交互。

添加Subtract API同步

我有一个余额存储在服务器的数据库中。我想要两个 API 添加到余额(添加金额) 从余额中减去(金额减去) 我的问题如下如果用户使用移动设备...

回答 1 投票 0

Retrofit 1.9 一直调用失败,返回null body

我正在尝试与我的 php Web 服务(Google App Engine)进行通信,但它一直以 body 为 null 进行响应,并且还触发了 Retrofit 的 failure() 方法(回调)。 我得到以下内容

回答 1 投票 0

java嵌套http调用API库

我正在从 playframework 阅读一些 http webservice API,链接如下。 我无法理解这种嵌套如何与平面图一起使用。 有人可以给我一些提示如何打击这个大c...

回答 1 投票 0

如何在.Net Framework 4.6中处理调用单线程Web服务的多线程测试?

我的生成身份验证 PIN 的 Web 服务不管理多线程,当它仅在一个线程中执行单个调用时,我们没有问题。该系统将被替换,但现在我需要

回答 1 投票 0

在网站和API之间共享信息

我有一个 REST API 为我的用户提供服务。我还有一个网站,允许我的用户获取一些信息并注册使用 API。 到目前为止,我的网站和 API 都完全正常

回答 1 投票 0

SOAP-错误:解析 WSDL:无法从 'xxx/?wsdl' 加载:标签 html 第 1 行中的数据过早结束

几天来,我遇到了一个错误,但无法找到解决方案来解决此问题。 WSDL...

回答 1 投票 0

在与 Spring boot 相同的端口中发布 JAXWS 端点

我在 JAXWS 的实现上遇到问题,因为公开端点将在 API 休息或默认 Spring Boot 端口的同一端口中使用肥皂消息。 我正在使用这个:

回答 1 投票 0

如何为 Web 服务中可能的扩展准备业务对象

在创建 Web 服务时,我决定在客户端和 Web 服务之间交换业务对象 (BO)。 如果将来我收到扩展模型并放入一些新属性(字段)的请求......

回答 2 投票 0

NodeJS http 和 https 模块有什么区别?

我在我的项目中使用http模块,但我的大多数“post”请求都被邮递员阻止了。 我读到这是一个 ssl 问题,经过一番研究,我发现了另一个名为 https 的模块。 这是我现在的同事...

回答 4 投票 0

网站、网络服务、网络 API

我是新来的,对一些事情感到困惑 一些网站(twitter、foursquare等)提供API给第三方开发者调用。这些 API 是网站提供的 Web 服务吗? 那些是……

回答 2 投票 0

从netsuite触发外部API [已关闭]

我是 NetSuite 新手,我需要将其与第三方系统集成。每次创建新的销售订单时,我都需要将其详细信息传递给第三方。 NetSuite有什么办法可以计算...

回答 2 投票 0

来自 Exchange Web 服务的响应是无效的 XML

我使用下面的代码对 Exchange-365 服务器进行身份验证并发送电子邮件,但我得到的结果是“从服务收到的响应不包含有效的 XML”。 代码是...

回答 1 投票 0

来自客户端的 WCF 端点发现;可以吗?

我认为我的问题很简单。 Web 客户端是否可以发现特定 WCF 服务可用的方法(通过 http://the.web.server/SomeWCFService.svc)? 这...

回答 1 投票 0

从 Oracle pl/sql 调用 Soap Web 服务出现错误

当我调用 SOAP 服务时,出现“ORA-29266:已到达正文末尾”错误。我使用公共测试 api 测试我的脚本”,例如 http://www.dataaccess.com/webservicesserver/NumberConversion.wso&qu...

回答 1 投票 0

PHP 从多个源加载第一个图像

假设有一个简单的网站,将用户图像托管在多个图像共享网站上,以确保一台服务器宕机不会损害用户页面的完整性。 有可能吗...

回答 2 投票 0

首先创建网络服务而不是网站,反之亦然

我计划为其他开发人员构建一个应用程序包,其中包括移动应用程序、网站和 Web 服务。网站优先,移动应用程序其次。 对于

回答 1 投票 0

AWS Lambda Web 服务调用

我设法在 Lambda 中实现以下工作(不抛出错误),但是如何查看实际的响应 JSON? var https = require('https'); Exports.handler = 函数(事件,上下文){ 嗯……

回答 1 投票 0

将SoapHeader添加到org.springframework.ws.WebServiceMessage

如何将对象添加到 org.springframework.ws.WebServiceMessage 的肥皂头中 这是我希望最终得到的结构: 如何将对象添加到org.springframework.ws.WebServiceMessage的soap标头中 这是我希望最终得到的结构: <soap:Header> <credentials xmlns="http://example.com/auth"> <username>username</username> <password>password</password> </credentials> </soap:Header> 基本上,您需要在客户端中使用 WebServiceMessageCallback 在消息创建之后、发送之前修改消息。 @skaffman 已经非常准确地描述了其余代码,因此整个内容可能如下所示: public void marshalWithSoapActionHeader(MyObject o) { webServiceTemplate.marshalSendAndReceive(o, new WebServiceMessageCallback() { public void doWithMessage(WebServiceMessage message) { try { SoapMessage soapMessage = (SoapMessage)message; SoapHeader header = soapMessage.getSoapHeader(); StringSource headerSource = new StringSource("<credentials xmlns=\"http://example.com/auth\">\n + <username>"+username+"</username>\n + <password>"+password"+</password>\n + </credentials>"); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(headerSource, header.getResult()); } catch (Exception e) { // exception handling } } }); } 就我个人而言,我发现 Spring-WS 很难满足这样的基本需求,他们应该修复 SWS-479。 您可以执行以下操作: public class SoapRequestHeaderModifier implements WebServiceMessageCallback { private final String userName = "user"; private final String passWd = "passwd"; @Override public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException { if (message instanceof SaajSoapMessage) { SaajSoapMessage soapMessage = (SaajSoapMessage) message; MimeHeaders mimeHeader = soapMessage.getSaajMessage().getMimeHeaders(); mimeHeader.setHeader("Authorization", getB64Auth(userName, passWd)); } } private String getB64Auth(String login, String pass) { String source = login + ":" + pass; String retunVal = "Basic " + Base64.getUrlEncoder().encodeToString(source.getBytes()); return retunVal; } } 然后 Object response = getWebServiceTemplate().marshalSendAndReceive(request, new SoapRequestHeaderModifier()); 您需要将 WebServiceMessage 转换为 SoapMessage,其中有一个 getSoapHeader() 方法可用于修改标题。反过来,SoapHeader有各种添加元素的方法,包括getResult()(可以用作Transformer.transform()操作的输出)。 I tried many options and finally below one worked for me if you have to send soap header with authentication(Provided authentication object created by wsimport) and also need to set soapaction. public Response callWebService(String url, Object request) { Response res = null; log.info("The request object is " + request.toString()); try { res = (Response) getWebServiceTemplate().marshalSendAndReceive(url, request,new WebServiceMessageCallback() { @Override public void doWithMessage(WebServiceMessage message) { try { // get the header from the SOAP message SoapHeader soapHeader = ((SoapMessage) message).getSoapHeader(); // create the header element ObjectFactory factory = new ObjectFactory(); Authentication auth = factory.createAuthentication(); auth.setUser("****"); auth.setPassword("******"); ((SoapMessage) message).setSoapAction( "soapAction"); JAXBElement<Authentication> headers = factory.createAuthentication(auth); // create a marshaller JAXBContext context = JAXBContext.newInstance(Authentication.class); Marshaller marshaller = context.createMarshaller(); // marshal the headers into the specified result marshaller.marshal(headers, soapHeader.getResult()); } catch (Exception e) { log.error("error during marshalling of the SOAP headers", e); } } }); } catch (Exception e) { e.printStackTrace(); } return res; } 您也可以通过创建子元素的键值映射来实现: final Map<String, String> elements = new HashMap<>(); elements.put("username", "username"); elements.put("password", "password"); 在soap标头中设置子元素的命名空间和前缀: final String LOCAL_NAME = "credentials"; final String PREFIX = ""; final String NAMESPACE = "http://example.com/auth"; 然后,您可以调用 WebServiceTemplate 的方法 marshalSendAndReceive,在其中重写 WebServiceMessageCallback 的方法 doWithMessage,如下所示: Object response = getWebServiceTemplate().marshalSendAndReceive(request, (message) -> { if (message instanceof SaajSoapMessage) { SaajSoapMessage saajSoapMessage = (SaajSoapMessage) message; SOAPMessage soapMessage = saajSoapMessage.getSaajMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); if (Objects.nonNull(elements)) { try { SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); SOAPHeader soapHeader = soapEnvelope.getHeader(); Name headerElementName = soapEnvelope.createName( LOCAL_NAME, PREFIX, NAMESPACE ); SOAPHeaderElement soapHeaderElement = soapHeader.addHeaderElement(headerElementName); elements.forEach((key, value) -> { try { SOAPElement element = soapHeaderElement.addChildElement(key, PREFIX); element.addTextNode(value); } catch (SOAPException e) { // error handling } }); soapMessage.saveChanges(); } catch (SOAPException e) { // error handling } } } }); 上述步骤导致: <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Header> <credentials xmlns="http://example.com/auth"> <password>password</password> <username>username</username> </credentials> </env:Header> <env:Body> <!-- your payload --> </env:Body> </env:Envelope> Response response = (Response)getWebServiceTemplate() .marshalSendAndReceive(request, new HeaderModifier()); 创建类 HeaderModifier 并重写 doWithMessage public class HeaderModifier implements WebServiceMessageCallback { private static PrintStream out = System.out; @Override public void doWithMessage(WebServiceMessage message) throws IOException { SaajSoapMessage soapMessage = (SaajSoapMessage) message; SoapEnvelope soapEnvelope = soapMessage.getEnvelope(); SoapHeader soapHeader = soapEnvelope.getHeader(); //Initialize QName for Action and To QName action = new QName("{uri}","Action","{actionname}"); QName to = new QName("{uri}","To","{actionname}"); soapHeader.addNamespaceDeclaration("{actionname}", "{uri}"); SoapHeaderElement soapHeaderElementAction = soapHeader.addHeaderElement(action); SoapHeaderElement soapHeaderElementTo = soapHeader.addHeaderElement(to); soapHeaderElementAction.setText("{text inside the tags}"); soapHeaderElementTo.setText("{text inside the tags}"); soapMessage.setSoapAction("{add soap action uri}"); soapMessage.writeTo(out); } }

回答 6 投票 0

限制 REST API 访问

我有一个面向公众的 API,它在内部使用 Google 地图 API 服务返回一些数据。该 API 目前主要用于内部目的,通过 Web 应用程序调用。 然而,我...

回答 1 投票 0

让 REST 与 SOAP 通信

我有两个系统,一个(我们称之为 S1)公开 RESTful API(我们称之为 WS1),另一个系统(我们称之为 S2)公开 SOAP API(我们称之为 WS2)。 我正在尝试找出一个...

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.