我有一个SOAP Web服务,可在多个服务器上使用,因此具有多个端点.我想避免添加具有不同名称的多个服务引用(C#SOAP端口客户端),以便与此服务进行通信,因为API完全相同.
有没有办法在运行时配置端点URI?
我的目标是使用mvn程序集创建一个在独立jar中运行的Web服务客户端,其中包含所有依赖项:single
我使用CXF codegen wsdl2java生成了客户端,创建了名为NetBanxAutostatementService的@WebServiceClient
对于我的依赖项
<cxf.version>2.5.2</cxf.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
<scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我甚至试图添加更多"东西"
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-core</artifactId>
<version>2.5.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf</artifactId>
<version>2.5.2</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
问题:每次我尝试运行"java -jar target/Netbanx-0.0.1-SNAPSHOT-jar-with-dependencies.jar"
INFO [main] (Netbanx.java:97) - autostatement_wsdlLocation:https://www.test.netbanx.com/cgi-bin/autostatement_wsdl
Exception in thread "main" java.lang.NullPointerException
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:92)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:204)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:148)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:91)
at javax.xml.ws.Service.<init>(Service.java:56)
at com.netbanx.autostatement.NetBanxAutostatementService.<init> (NetBanxAutostatementService.java:39)
at my.project.netbanx.Netbanx.<init>(Netbanx.java:98)
at my.project.netbanx.Netbanx.main(Netbanx.java:130)
Run Code Online (Sandbox Code Playgroud)
这发生在调用WebServiceClient autostatementService = new NetBanxAutostatementService(autostatement_wsdlLocation)的行中; 我在日志行中知道我没有将autostatement_wsdlLocation传递为null
Java代码:
URL autostatement_wsdlLocation = null;
URL payment_wsdlLocation = null;
try …Run Code Online (Sandbox Code Playgroud) 我有一个案例,我需要生成两个CSharp代码文件具有相同的代码但不同的方法的输入和输出类型的命名空间.实际上,每个文件都针对特定国家/地区,而且类型来自特定国家/地区的WSDL.
我正在围绕服务编写一些包装器,逻辑完全相同,但是从WSDL自动生成的类型是不同的.我怎样才能减少编码工作量并在一个地方编写逻辑并为两组不同类型生成逻辑?
我正在使用JAXWS为我们正在构建的Java应用程序生成WebService客户端.
当JAXWS构建其XML以在SOAP协议中使用时,它会生成以下名称空间前缀:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body ...>
<!-- body goes here -->
</env:Body>
</env:Envelope>
Run Code Online (Sandbox Code Playgroud)
我的问题是我的Counterpart(一家大型转账公司)管理我的客户端连接的服务器,拒绝接受WebService调用(请不要问我的原因),除非XMLNS(XML namepspace前缀是soapenv).像这样:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body ...>
<!-- body goes here -->
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:
有没有办法命令JAXWS(或任何其他Java WS客户端技术)使用soapenv而不是env作为XMLNS前缀来生成客户端?是否有API调用来设置此信息?
谢谢!
我正在寻找一个简单的C++ WebService客户端库,可以轻松链接到我的应用程序中.
最好这个库:
在你们任何人回答.NET之前:去过那里,尝试过.我对.NET的主要反对意见是:
我已经使用谷歌查找这些信息,但我找不到一个.
谢谢
编辑: 为了进一步澄清这一点,我真的想要一些我可以编写这样的代码(或者这种风格的东西):
SoapClient mySoapClient;
mySoapClient.setURL("http://someserver/somewebservice");
mySoapClient.setMethod("DoSomething");
mySoapClient.setParameter(1,"Hello");
mySoapClient.setParameter(2,12345);
mySoapClient.sendRequest();
string result;
mySoapClient.getResult(result);
Run Code Online (Sandbox Code Playgroud)
没有动态代码生成.
我正在使用NSIS构建安装程序,作为该安装程序的一部分,我获得了WCF服务的详细信息(即Url,用户名和密码).我需要验证这些细节.
在C#中,我创建了一个服务引用,并简单地执行以下操作:
var proxy = new ServiceClient(httpsBinding, serviceEndpointAddress);
proxy.ClientCredentials.UserName.UserName = userName;
proxy.ClientCredentials.UserName.Password = password;
try
{
proxy.Open();
}
catch (EndpointNotFoundException ex)
{
// Return the end point's not valid
}
etc
Run Code Online (Sandbox Code Playgroud)
现在我需要在C++中执行此操作,因此可以从NSIS调用它(我已经研究过从NSIS调用C#的方法,它们对于我想做的事情似乎都有点过分).我已经设法转换生成绑定和终点地址的代码但是我坚持创建ServiceClient.
我已经为项目添加了"Web引用",但是ServiceClient在ServiceReference命名空间中没有相应的内容.这个:
ServiceReference::ServiceClient ^service = gcnew ServiceReference::ServiceClient(httpsBinding, endpointAddress);
Run Code Online (Sandbox Code Playgroud)
不编译为:
'ServiceClient':不是'ServiceReference'的成员
那么我该如何创建客户端呢?
我使用eclipse Helios创建了一个Web服务客户端,用于使用轴1.4 Web服务.
它生成了2个包:
1 - datamodel.
2 - 客户.
内部客户端包有5个类:
1- ServiceName
2- ServiceNameProxy
3- ServiceNameService
4- ServiceNameServiceLocator
5- ServiceNameSoapBindingStub
我需要知道这些是什么?和
如何使用参数调用Web服务方法?
提前致谢
尽管如此我已经定义了相关的依赖项,如下所示,java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl当我的应用程序调用Web服务时获取异常.
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.10</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.10</version>
<type>pom</type>
</dependency>
Run Code Online (Sandbox Code Playgroud)
ps servlet容器是Apache Tomcat 9.0.4.
ps Java版:9.0.1.
我有一个WebMethod,其参数定义为DateTime.我打电话的时候
webservice,我收到此错误:
在System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()在System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(深度Int)在System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(深度Int)在的System.Web .Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(深度Int)在System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(字符串输入,的Int32 depthLimit,JavaScriptSerializer串行器)在System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer串器,串输入,类型类型,的Int32 depthLimit)在System.Web.Script.Serialization.JavaScriptSerializer.Deserialize [T](字符串输入)在System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext的上下文中,JavaScriptSerializer串行器)在系统. Sys的Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData,HttpContext context)tem.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context,WebServiceMethodData methodData)"
这是我的WebService:
/// <summary>
/// Summary description for AgendamentoService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class AgendamentoService : System.Web.Services.WebService
{
public AgendamentoService()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public CompromissoWekCalendarVO[] GetCompromissos(int id_pessoa, DateTime start, DateTime end)
{
bo.CompromissoBO compBO = new bo.CompromissoBO();
return compBO.Get(id_pessoa,start, end).ToArray();
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,我的客户端代码:
var params = '{id_pessoa: "' + id_pessoa + '", start:/Date('+ start.getTime()+')/, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用标准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)