我试图调用一个具有基本HTTP身份验证的Web服务.我使用AXIS的WSDL2JAVA工具生成了客户端代码.
但是我无法为webservice调用设置用户名和密码.
我试着把它们放在端点url中
但是我收到了未经授权的错误.我试图找到一种方法来将此设置用于Java代码中的调用....
注意:我可以通过soapUI调用相同的服务并获得结果.我在请求的"自动"选项卡中提供了用户名和密码.
以下是我的Stub的一些代码片段,如果这对您有用
_serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service);
_serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(
targetEndpoint));
_serviceClient.getOptions().setUseSeparateListener(useSeparateListener);
//adding SOAP soap_headers
_serviceClient.addHeadersToEnvelope(env);
// set the message context with that soap envelope
_messageContext.setEnvelope(env);
// add the message contxt to the operation client
_operationClient.addMessageContext(_messageContext);
//execute the operation client
_operationClient.execute(true);
Run Code Online (Sandbox Code Playgroud)
任何投入将不胜感激!!
我正在构建一个Web服务客户端,以便与一个(基于java的)远程Web服务进行交互,这是我无法控制的.我可以调用Web服务操作,并通过数据包嗅探告诉服务正在响应填充的数据.但是,当响应进入客户端代码时,响应只是一个shell,所有数据都为null.
我怀疑在Web服务"管道"中发生了一个错误,导致数据被静默删除或忽略,但我找不到一种方法来启用调试(甚至日志或错误消息?)在它命中我的客户端代码之前的响应.
我的App.config启用了消息日志记录,但只记录了外发消息:
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="messages"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\messages.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="3000"
maxSizeOfMessageToLog="2000"/>
</diagnostics>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
我真的想在实际解析响应消息期间设置断点,但让Message Logger实际记录响应也可能有所帮助.
我还配置了一个自定义MessageEncoder,它是解决远程服务解析器中的错误所必需的.我可以在这个ReadMessage方法上添加断点MessageEncoder,并且可以看到数据在那时仍然存在.但是,下一步跳回到客户端代码,并且Response对象为空 - 没有警告或消息.有什么方法可以看到两者之间发生了什么?
所以,我想这最终是一个由两部分组成的问题:
MessageEncoder,但在它被发送到客户端代码之前?我正在尝试访问我正在处理的项目的Web服务.我正在使用JAX-WS,应用程序部署在weblogic上.当我试图访问WS时,我得到以下异常:
javax.portlet.PortletException: javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://xxx.xxxx.ro:40000/idm/ws/cup?wsdl. It failed with:
Response: '401: Unauthorized' for url: 'http://xxx.xxxx.ro:40000/idm/ws/cup?wsdl'.
at com.bea.portlet.container.PortletStub.processAction(PortletStub.java:346)
at com.bea.portlet.container.AppContainer.invokeProcessAction(AppContainer.java:678)
........
Run Code Online (Sandbox Code Playgroud)
我阅读了很多关于问题的帖子,我尝试了不同类型的auth.我尝试在不同的用例中使用BindingProvider,basicHTTPAuth,禁用HostnameVerifier等但仍然没有结果.
以下是我的代码片段,作为最后一个尝试过的版本:
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
username,
password.toCharArray());
}
});
ComputeUserProfileImplService computeUserProfileImplService = new ComputeUserProfileImplService(
new URL(null, endpointURL, new sun.net.www.protocol.http.Handler()),
new QName("http://xxx.xx.xxxxx.xxxxx.com/",
"ComputeUserProfileImplService"));
ComputeUserProfileImpl computeUserProfile = computeUserProfileImplService
.getComputeUserProfileImplPort();
Run Code Online (Sandbox Code Playgroud)
ComputeUserProfileImplService代码如下所示:
private final static URL COMPUTEUSERPROFILEIMPLSERVICE_WSDL_LOCATION;
private final static Logger logger = Logger.getLogger(com.xxxxx.xxxxx.xx.xxxxx.cup.ComputeUserProfileImplService.class.getName());
static {
URL url = null;
try { …Run Code Online (Sandbox Code Playgroud) 我在使用基于Soap的Web服务的projet工作,使用基于Soap的Web服务和2个本地智能手机应用程序(ios和android),经过webservice开发团队的一些编辑后,PHP方面的事情被破坏但智能手机应用程序没有问题.
这是一个重现问题的简单脚本
<?php
error_reporting(E_ALL);
$url = 'http://www.xxxxx.com/service.awws?wsdl';
$sKey = 'thekey';
$client= new SoapClient($url, array('trace' => 1,
'exception' => 1,
'encoding' => 'UTF-8',
'cache_wsdl' => WSDL_CACHE_NONE));
$params = array('sKey' => $sKey, 'nLangID' => 1);
$res = $client->TPGetLocalisationVersion($params);
echo '<pre>Res : ';
print_r($res);
echo '</pre>';
?>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Fatal error: Uncaught SoapFault exception:
[HTTP] Unable to parse URL in /home/xxxx/www/test.php:14 Stack trace: #0 [internal function]:
SoapClient->__doRequest('__call('TPGetLocalisati...', Array) #2 /home/tmpweb/www/test.php(14):
SoapClient->TPGetLocalisationVersion(Array) #3 {main} thrown in /home/xxxx/www/test.php on line 14
Run Code Online (Sandbox Code Playgroud)
方法TPGetLocalisationVersion存在且参数正确.这段代码以前用于工作.
我也可以使用wget从PHP Webserver获取wsdl.
我用一些在线工具测试了WSDL文件,看起来没问题.
有没有调试这个的建议?我确信WSDL没有缓存,因为我在专用服务器上并且在php.ini中完全禁用了WSDL缓存
现在我正在尝试使用来自 Unix 平台的 Curl 命令调用 Web 服务。Web 服务在外部服务器上可用。我只能使用 telnet 连接外部服务器。Web 服务使用基本身份验证,我必须提供用户名和密码。
任何人都可以帮助我以正确的方式执行此操作吗?
我创建了一个 Java 客户端,以使用 Axis2 (1.7.6) 作为代码生成器与 SOAP Web 服务进行交互。问题是客户端在某些输入中抛出异常消息:
org.apache.axis2.AxisFault: Invalid white space character (0x4) in text to output (in xml 1.1, could output as a character entity)
似乎序列化程序遇到了一些被认为对 XML 规范无效的字符。我已经看到了这个问题,但没有明确的答案或修复。我没有使用 Spring 或任何其他依赖注入框架,它是一个独立的应用程序,所以我需要手动配置 Axis2 的内部。
关于如何正确修复/配置客户端的任何想法?
我有一个 Maven 项目,它将使用许多网络服务。该应用程序将被打包为 WAR。到目前为止,客户的代码已cxf-codegen-plugin在 ,generate-sources阶段生成。默认情况下,生成的源放置在 中target/generated-sources/cxf,之后compile,它们被编译并与 中的应用程序类混合target/classes。生成的类和应用程序类都可以共享第一级包。
我希望每个客户端都打包在WEB-INF/libWAR 文件中的自己的 JAR中。我发现了 about -clientjar,但它只生成.jar文件并将它们放入target/generated-sources/cxf,并且 JAR 也最终target/classes与编译的类一起出现,这是毫无意义的。
我想该compile插件在某个时候正在将生成的源编译为target/classes,并且可能另一个阶段也在将 JAR 移到那里。是否有可能让 Maven 避免编译那些生成的源代码(甚至根本不cxf-codegen-plugin生成源代码,只生成 JAR),并针对 CXF 生成的 JAR 编译应用程序类?
我知道可以通过为每个 Web 服务定义一个带有 jar 打包模块的多模块项目来实现这一点,但我想避免使用此选项。可能有大量的 Web 服务,不适合为每个服务维护一个独立的模块。随着-clientjar我已经被迫定义<wsdlOption>,以提供每个WSDL的JAR名为每个WSDL(这是不可能的,让cxf-codegen-plugin刚刚扫描src/main/resources/wsdl或<wsdlRoot>)。
当然,客户端 JAR 可以在 Maven 之外生成并安装到本地存储库,并在项目中定义为依赖项,但我想知道是否可以在单个 Maven 构建中执行此操作。
对于程序集,我可能会整理出如何放置由-clientjarinto生成的 JAR 文件,WEB-INF/lib但在 …
最近,我花了几个小时试图让WSImport处理通过HTTPS托管的Web服务,使用伪证书(开发部署).
我试过用wsimport.exeJava 8 jdk的windows版本.
我指定了选项-XdisableSSLHostnameVerification,但它一直在抱怨错误的证书.这是事实,证书无效,但在开发环境中,它应该是可以接受的.
我没有找到简单的方法让wsimport跳过证书检查.
我有一个wpf应用程序,并且在相同的基本url上调用4个Web服务(书面Java),并且在我安装google chrome之前它一直运行良好。我安装了chrome,但出现了这个错误:
无法为SSL / TLS C#Web服务建立安全通道
我没有写另一个代码。那只是我安装了chrome然后删除了chrome但没有用,并且尝试了系统还原,卸载eset smart security并清理了所有Windows(8.1种单一语言)证书的情况。想办法。这是我的网络服务呼叫者
public string call(string url, string json)
{
try
{
var webrequest = (HttpWebRequest)WebRequest.Create(url);
var key = JsonConvert.SerializeObject(LoginService.SessionData.SessionKey);
UTF8Encoding uTF8Encoding = new UTF8Encoding();
byte[] requestBytes = uTF8Encoding.GetBytes(json);
WebClient client = new WebClient();
webrequest.Method = "POST";
webrequest.Headers.Add("SESSION_KEY", LoginService.SessionData.SessionKey);
webrequest.ContentType = "application/json";
webrequest.ContentLength = requestBytes.LongLength;
Stream requestStream = webrequest.GetRequestStream();//here the exception
requestStream.Write(requestBytes, 0, requestBytes.Length);
using (var response = webrequest.GetResponse())
using (var reader = new StreamReader(response.GetResponseStream()))
{
var responseBuf = reader.ReadToEnd();
String responseJson = Convert.ToString(responseBuf); …Run Code Online (Sandbox Code Playgroud) 我使用C#创建了一个新的Azure Functions项目。我看不到添加“连接的服务”的任何选项,因此我可以为要调用的SOAP API生成代理。如何使用Azure Functions做到这一点?