我正在尝试使用标准JAVA 7 JAX WS工具来使用安全(HTTPS模式)Web服务.此Web服务需要身份验证.
我已经成功将证书添加到我的本地java密钥库.我借助wsimport工具从WSDL文件生成所有需要的类.
现在我尝试使用以下调用来运行一个简单的测试:
public class ReportingWebServiceTest {
static ReportingServiceService service;
static ReportingService port;
@BeforeClass
public static void setUpBeforeClass(){
service = new ReportingServiceService();
port = service.getReportingServicePort();
Map<String, Object> rContext = ((BindingProvider) port).getRequestContext();
Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("Authorization", Collections.singletonList("Basic YWRtaW5AYWRhcHRsb2dpYy5jb206MTIxMjE****="));
// headers.put("Username", Collections.singletonList("*****@******.com"));
// headers.put("Password", Collections.singletonList("********"));
rContext.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
// rContext.put(BindingProvider.USERNAME_PROPERTY, "*****@******.com");
// rContext.put(BindingProvider.PASSWORD_PROPERTY, "********");
}
@Test
public void test() {
WEBCAMPAIGNROW row = port.getCampaignRowById(14081);
toConsole(row.toString());
}
protected static void toConsole(String msg) {
System.out.println(msg);
} …Run Code Online (Sandbox Code Playgroud) 所以我已经研究了如何将我的自定义对象传递到ASP.Net json webservices.有魅力.
我遇到的问题是传递自定义对象的直接数组,或者传入作为自定义对象参数的数组.
所以例如......
Public Class WebService1
Inherits System.Web.Services.WebService
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function AddPersonList(ByVal PersonList As PersonList) As String
Debug.Assert(False)
End Function
Public Class Person
Public Sub New()
End Sub
Public Property FirstName As String
Public Property LastName As String
End Class
Public Class PersonList
Inherits List(Of Person)
End Class
End Class
<script>
$(function () {
$.ajax({
type: "POST",
url: "WebService1.asmx/AddPersonList",
data: " { PersonList: [ { FirstName: 'Max', LastName: 'Gershkovich' }, { FirstName: 'Test1', LastName: 'Test2' …Run Code Online (Sandbox Code Playgroud) 我们有一个需要使用外部Web服务的应用程序.为此,我们使用cxf-codegen-plugin插件提供的wsdl2java目标,通过Maven从WSDL生成了一组Java工件.
在应用程序中,我们希望将端点设置为在运行时用于Web服务调用(以满足测试环境中的不同Web服务端点URL),因此编写了一些代码,如下所示为我们执行此操作:
private <T> T createServiceObject(final Class<T> p_seiClass) throws MalformedURLException {
final Service serviceFactory = Service.create(new URL(wsdlLocation), new QName(targetNamespace, serviceName));
final T service = serviceFactory.getPort(p_seiClass);
((BindingProvider) service).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "endpoint");
return service;
}
Run Code Online (Sandbox Code Playgroud)
当代码运行时,它在serviceFactory.getPort行上失败,并带有以下execption:
javax.xml.ws.WebServiceException: class ZZZ.YYYwebservice.v5.types.ProcessUIRequestResponse do not have a property of the name ProcessUIRequestResult
at com.sun.xml.internal.ws.client.sei.ResponseBuilder$DocLit.<init>(ResponseBuilder.java:512)
at com.sun.xml.internal.ws.client.sei.SEIMethodHandler.buildResponseBuilder(SEIMethodHandler.java:172)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.<init>(SyncMethodHandler.java:86)
at com.sun.xml.internal.ws.client.sei.SEIStub.<init>(SEIStub.java:83)
at com.sun.xml.internal.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:641)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:344)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:326)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:364)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:368)
at javax.xml.ws.Service.getPort(Service.java:172)
at com.XXX.XXX.XXX.YYY.integration.facade.jaxws.ProcessUIRequestFacadeJaxws.createServiceObject(ProcessUIRequestFacadeJaxws.java:53)
at com.XXX.XXX.XXX.YYY.integration.facade.jaxws.ProcessUIRequestFacadeJaxws.processUIRequest(ProcessUIRequestFacadeJaxws.java:39)
at com.XXX.XXX.XXX.YYY.integration.facade.jaxws.ProcessUIRequestFacadeJaxwsTest.test(ProcessUIRequestFacadeJaxwsTest.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at …Run Code Online (Sandbox Code Playgroud) 我想在c#应用程序中使用Google Webmaster Tool API.我浏览了https://developers.google.com上提供的各种文档.不幸的是,我没有得到任何使用.Net的Google WT API的工作示例.我也看过"客户端库"(" https://developers.google.com/gdata/docs/client-libraries ").
任何人都可以向我提供有关如何在c#中使用Google网站管理员工具API的任何实际示例吗?
我在Google WT上有帐号,想要下载.CSV报告"CrawlErrors","InternalLinks","TopSearchQueries"等.
谢谢
我正在为iPhone开发一个应用程序,它从Web服务获取数据库中的所有数据.我收到JSON格式的信息,并不断调用Web服务来获取数据.我的问题是我应该使用核心数据吗?现在我只是向Web服务请求使用我需要的信息,并在需要时调用数据.但是我应该将数据放入核心数据中,因为我无法确定它是否有帮助甚至是有意义的.由于服务器上有数千行数据,我无法想象不断将信息保存到核心数据中,从而将数据库从服务器复制到手机上.这似乎没有意义,也不是表现明智的好主意.我不会最终在核心数据库中耗尽空间或在设备上占用太多空间吗?也许我没有完全理解这个概念.
我遇到了问题,因为我有一个带有wsHttpBinding的Web服务:
<endpoint address="" binding="wsHttpBinding" contract="BindingTest.IService1" />
Run Code Online (Sandbox Code Playgroud)
我无法让我的python代码调用它,每次我尝试调用时都会收到此错误消息:
Exception: (400, u'Bad Request')
Run Code Online (Sandbox Code Playgroud)
经过多次调查并在互联网上搜索后,我只是在我的Web服务中指定了basicHttpBinding:
<endpoint address="basic" binding="basicHttpBinding" contract="BindingTest.IService1" />
Run Code Online (Sandbox Code Playgroud)
通过这种方式,我可以从python代码调用Web服务!
现在我的问题是另一个:我无法真正修改Web服务,我可以在本地尝试,但我没有权限修改它.
那么,有没有办法在python中指定一个"wsHttpBinding"请求?
这是我的实际代码:
import logging
from suds.client import Client
import sys
from suds.sax.element import Element
handler = logging.StreamHandler(sys.stderr)
logger = logging.getLogger('suds.transport.http')
logger.setLevel(logging.DEBUG), handler.setLevel(logging.DEBUG)
logger.addHandler(handler)
client =Client('Service_URL')
client.set_options(headers={'Content-Type': 'application/soap+xml; charset=utf-8'})
result = client.service.RouteDocument('Input')
Run Code Online (Sandbox Code Playgroud) 是否有免费的webservice/api(在雅虎或其他平台上)可以返回贵金属价格(金,银,铂,钯)的实时股票价格?
这是付费服务:http://www.kitco.com/market/
(如果它来自Yahoo Query Language会很棒)
几天我们的应用程序出现问题.我们使用SoapHttpClientProtocol来调用java mbeans.这基本上调用java webservice来调用方法.
我们的问题是,有时我们会得到以下异常:
XML文档中存在错误(1,172089).
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse上的System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader,String encodingStyle)中的System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader,String encodingStyle,XmlDeserializationEvents事件)处(位于JMXConnectorService.cs的DynamicMBeanResourceBinding.Invoke(OperationRequestType ManagedResourceOperation)中的System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName,Object []参数)中的SoapClientMessage消息,WebResponse响应,Stream responseStream,Boolean asyncCall:JMXWSClient中的第781行连接\ Client.cs中的.InvokeMethodOnObject(String objectName,String methodName,ParameterType [] paramValue):第132行引起:发生了意外的文件结束.以下元素未关闭:图标
我们在通信层中的最后一个代码是:
/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("soapHeaders", Direction = SoapHeaderDirection.In)]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://jsr262.dev.java.net/DynamicMBeanResource/Invoke", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("ManagedResourceOperationResult", Namespace = "http://jsr262.dev.java.net/jmxconnector")]
public GenericValueType Invoke([System.Xml.Serialization.XmlElementAttribute(Namespace = "http://jsr262.dev.java.net/jmxconnector")] OperationRequestType ManagedResourceOperation)
{
object[] results = this.Invoke("Invoke", new object[] {ManagedResourceOperation});
return ((GenericValueType)(results[0]));
}
Run Code Online (Sandbox Code Playgroud)
在框架反序列化之前,有没有办法记录响应xml?任何帮助或想法都非常受欢迎.
我有一组相关的Web服务,它们在它们之间共享某些类型,特别是TokenService生成的“令牌”。
在Visual Studio中使用“添加引用”时,将生成代理类,并且每个Web服务都将复制许多类(例如Token类)。
为了解决这个问题,我编写了以下powershell脚本来为可重复使用类型的Web服务生成.cs文件。
$svcutil = get-item ((get-item 'Env:\ProgramFiles(x86)').Value + "\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\svcutil.exe")
$csc = "C:\Program Files (x86)\MSBuild\14.0\Bin\csc.exe"
& $svcutil "http://Path/to/WebService/WSTokenService?wsdl" /o:WSTokenService.cs
& $csc /target:library /out:temp.dll WSTokenService.cs
& $svcutil "http://Path/to/WebService/WSAssetService?wsdl" /r:temp.dll /o:WSAssetService.cs
& $csc /target:library /out:temp.dll WSTokenService.cs WSAssetService.cs
& $svcutil "http://Path/to/WebService/WSContactService?wsdl" /r:temp.dll /o:WSContactService.cs
& $csc /target:library /out:temp.dll WSTokenService.cs WSAssetService.cs WSContactService.cs
..
repeat for 8 webservices
Run Code Online (Sandbox Code Playgroud)
这将Web服务“链接”在一起,重新使用共享的类,并且似乎可以正常工作。
这种方法是否有问题,和/或是否有更好的方法来实现相关Web服务之间的共享类?
编辑:请注意,这些不是我们开发的Web服务,我们无权访问服务器端使用的代码或类。
我想为以下 e2e 场景添加一个测试:
我的应用程序通过内部代理服务器向外部服务发出 Web 请求,代理服务器操作请求正文,将请求转发到目标主机并返回返回的响应。
举例来说,我对external.service/an/endpoint(通过my-proxy-server)正文做了一个发布请求
{
"card_number": "<proxy server pls fill the cc details>"
}
Run Code Online (Sandbox Code Playgroud)
代理服务器修改请求填写cc详细信息并转发给external.service/an/endpointwith body
{
"card_number": "372735466563005"
}
Run Code Online (Sandbox Code Playgroud)
external.service 返回状态 OK。代理服务器不加修改地返回响应。
如何使用wiremock 测试此工作流程?我可以WireMock.stubFor()为external.service,但我不知道如何使有线模拟代理与我的 Web 客户端的代理设置一起工作。查看测试,实际上,Rest Template 测试restTemplateWithWireMockAsProxyServer按预期工作,通过代理路由我的请求,但webClientWithWireMockAsProxyServer我的 RCA 出现错误:
20:06:59.165 [qtp105751207-24] DEBUG wiremock.org.eclipse.jetty.server.HttpChannel - REQUEST for //localhost:58978localhost:58978 on HttpChannelOverHttp@4a71ab50{r=1,c=false,c=false/false,a=IDLE,uri=//localhost:58978localhost:58978,age=0}
CONNECT //localhost:58978localhost:58978 HTTP/1.1
Host: localhost:58978
Run Code Online (Sandbox Code Playgroud)
正如这里提到的,这些通过 wiremock 代理的调用是不可能的。但是我所有的网址都像http://localhost:<port>,这意味着我没有进行任何 https 调用。
package com.spotnana.obt.supplier.services;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration; …Run Code Online (Sandbox Code Playgroud) c# ×4
web-services ×4
java ×3
api ×2
jax-ws ×2
.net ×1
asp.net ×1
core-data ×1
cxf ×1
ios ×1
javascript ×1
jaxb ×1
jquery ×1
objective-c ×1
proxy ×1
python ×1
spring-boot ×1
vb.net ×1
wiremock ×1
xml ×1