标签: webservice-client

PHP soapCall 生成不需要的 htmlEntities

我的 PHP 代码尝试与 Web 服务通信。

我想发送: <ns1:in0><![CDATA[<node>

但是 PHP 发送: <ns1:in0>&lt;![CDATA[&lt;node&gt;

如果我<-version在 SoapUI 中发送请求,它工作正常。

如果我&lt;-version 在 SoapUI 中发送请求,它会返回错误。

我的代码(没有私人信息):

    <?php
    $wsdl_path='https://....wsdl';
    $ws_path='https://...';
    $var='<![CDATA[<node>
             <subnode1>
             ...
             </subnoden>            
             </node>]]>';
    $methodName='methodName';

    $soapClient = new SoapClient($wsdl_path,array('location'=>$ws_path,'trace'=>true,'exceptions'=>false));
    $result = $soapClient->__soapCall($methodName,array(array("in0"=>($var))));

    echo "RESULT:\n";
    var_dump($result);
    echo "\n************************\n";
    echo "REQUEST:\n" . $soapClient->__getLastRequest();
    echo "\n************************\n";
    echo "REQUEST HEADERS:\n" . $soapClient->__getLastRequestHeaders();
    echo "\n************************\n";
    echo "RESPONSE:\n" . $soapClient->__getLastResponse();
    echo "\n************************\n";
    echo "RESPONSE HEADERS:\n" . $soapClient->__getLastResponseHeaders();
    echo "\n************************\n";
    ?>
Run Code Online (Sandbox Code Playgroud)

我的代码运行:

RESULT:
object(stdClass)#2 (1) {
  ["out"]=>
  NULL
}

************************
REQUEST: …
Run Code Online (Sandbox Code Playgroud)

php xml soap-client webservice-client html-entities

5
推荐指数
1
解决办法
1308
查看次数

javax.xml.ws.soap.SOAPFaultException:读取 XMLStreamReader 时出错:[row,col {unknown-source}] 处的序言中出现意外的 EOF:[1,0]

我正在尝试通过 https 协议调用肥皂网络服务。

我有 wsdl 并使用 Apache CXF 生成类,版本:3.0.5

当我在soapui中发布请求时,我从服务器得到成功的响应

但是当从 Java 客户端调用相同的方法时,会出现错误:javax.xml.ws.soap.SOAPFaultException: Error reading XMLStreamReader: Unexpected EOF in prolog

下面是java代码

package com.cts.pepsi.util;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.xml.ws.BindingProvider;

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.DocumentDetails;
import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.ErpIntegrationService;
import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.ErpIntegrationService_Service;
import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.EssJob;
import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.ObjectFactory;



public class SoapClient {
    private static final Logger           log      = LoggerFactory.getLogger(SoapClient.class);

    private String username = "username";
    private String password = "password";

    static ErpIntegrationService erpIntegrationService;
    static long value = …
Run Code Online (Sandbox Code Playgroud)

java soap cxf webservice-client webservices-client

5
推荐指数
0
解决办法
2万
查看次数

异步webservice调用.没有(开始...)方法可用!

我知道这已经解决了,但我有服务返回一个像这样的字符串.

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class MyService : System.Web.Services.WebService
{

    [WebMethod]
    public string Hello()
    {
        System.Threading.Thread.Sleep(10000);
        return "Hello User";
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经阅读了很多例子,说我需要调用这样的方法:

        MyService my = new MyService();
        AsyncCallback async = new AsyncCallback(callback);
        my.BeginHello();
        Console.WriteLine("Called webservice");
Run Code Online (Sandbox Code Playgroud)

事情就是当我添加引用时,我没有得到BeginHello方法.我看到的只是HelloAsync.所以我在我的控制台应用程序中使用它.

        MyService my = new MyService();
        AsyncCallback async = new AsyncCallback(callback);
        my.HelloAsync();
        Console.WriteLine("Called webservice");
Run Code Online (Sandbox Code Playgroud)

并定义了这样的私有回调方法

    private void callback(IAsyncResult res)
    {
        Console.Write("Webservice finished executing.");
    }
Run Code Online (Sandbox Code Playgroud)

这样做,我收到这样的错误:

非静态字段,方法或属性'AsyncWebserviceCall.Program.callback(System.IAsyncResult)需要对象引用

为什么我没有获得BeginHello方法?为什么我会得到如上所述的错误?

谢谢你的时间.

.net c# asynchronous webservice-client

4
推荐指数
1
解决办法
1万
查看次数

定义自定义命名空间以封装来自wsdl - Axis2 eclipse的生成文件的映射

我在Eclipse中有wsdl文件,我通过axis2插件生成客户端.

这些文件正生成到源文件夹中名为com.mycompany.stub的包中.

我想将生成的源文件的包名称更改为com.mycompany.ws.workflow

我在哪里可以在wsdl文件中执行此操作?

java eclipse axis2 webservice-client

4
推荐指数
1
解决办法
1万
查看次数

创建Web服务客户端时出错

我已经创建了一个用于访问database.it工作正常的web服务.但是当我尝试使用它的WSDL创建客户端时它会给出错误

    "The Apache Axis2 Web service runtime does not support the client project"
Run Code Online (Sandbox Code Playgroud)

我正在使用tomcat 6.0和Axis2.创建客户端我创建了java项目,然后尝试创建客户端.SO我不知道为什么会出现这个错误.对于axis2,客户端项目是动态Web项目吗?

java axis2 web-services webservice-client

4
推荐指数
1
解决办法
9701
查看次数

无法捕获 AxisFault 异常

我有一个代码,它是围绕 Web 服务的 java 包装器,在异常时它会抛出 AxisFault 异常(如下所示)

org.apache.axis2.AxisFault: Policy enforcement failed to authenticate the request.
    at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:446)
    at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:371)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at com.tibco.n2.de.services.EntityResolverServiceStub.lookupUser(EntityResolverServiceStub.java:261)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
Run Code Online (Sandbox Code Playgroud)

代码如下所示,

try {
                lookupUserResponse = myIntializedObject.lookupUser("someuser", null, null, true);
            } catch (InvalidServiceRequestFault e) {
                // TODO Auto-generated catch block
                //e.printStackTrace();
            } catch (InternalServiceFault e) {
                // TODO Auto-generated catch block
                //e.printStackTrace();
            } catch (SecurityFault e) {
                // TODO Auto-generated catch block …
Run Code Online (Sandbox Code Playgroud)

java web-services webservice-client

4
推荐指数
1
解决办法
1万
查看次数

如何通过https使用wsdl2java生成客户端代码?

我正在使用 Tomcat 6 和 CXF 3 来实现一些 Web 服务。我需要在本地服务器上使用 wsdl2java 命令生成客户端代码。它适用于 http 协议:

wsdl2java -frontend jaxws21 -p com.activenetwork.iam.ws.client -d "D:\devtools\workspace\TestClient\src" -encoding utf-8 -client -V http://localhost:8080/IAM/services/employee?wsdl
Run Code Online (Sandbox Code Playgroud)

但是,在我将服务器更新为 https 协议后,该命令不再起作用

wsdl2java -frontend jaxws21 -p com.activenetwork.iam.ws.client -d "D:\devtools\workspace\TestClient\src" -encoding utf-8 -client -V https://localhost:8443/IAM/services/employee?wsdl
Run Code Online (Sandbox Code Playgroud)

我得到以下错误:

Loading FrontEnd jaxws21 ...
Loading DataBinding jaxb ...
wsdl2java -frontend jaxws21 -p com.activenetwork.iam.ws.client -d D:\devtools\workspace\TestClient\src -encoding utf-8 -client -V https://localhost:8443/IAM/services/employee?wsdl
wsdl2java - Apache CXF 3.0.0-milestone2


WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: FAIL_TO_CREATE_WSDL_DEFINITION

org.apache.cxf.tools.common.ToolException: org.apache.cxf.wsdl11.WSDLRuntimeException: FAIL_TO_CREATE_WSDL_DEFINITION
        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:420)
        at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
        at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
        at …
Run Code Online (Sandbox Code Playgroud)

https cxf wsdl2java webservice-client

4
推荐指数
1
解决办法
2万
查看次数

使用 Ws 导入创建客户端不生成服务和端口类

我在我的应用程序中使用 Ws gen 生成了 wsdl。对于那个 wsdl,我尝试生成客户端,因此使用 Maven 导入 Ws。客户端生成成功,但只创建了请求、响应、异常、对象工厂和包类。

没有用于服务引用的类。问题是什么?

如果不需要服务类如何从我的客户端文件调用服务

谢谢

webservice-client

4
推荐指数
1
解决办法
1797
查看次数

WebService客户端和列表<JAXBElement <?>>

当我尝试从wsdl文档生成客户端时,我得到一个似乎有很多JAXBElement属性的客户端,例如

protected List<JAXBElement<?>> nameOrLinkingNameOrFamilyName;
Run Code Online (Sandbox Code Playgroud)

我使用soapUI生成apache cxf 2.3.3作为工具,也作为配置文件生成如下:

<jaxb:bindings version="2.1"
 xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
 xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" 
 xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
 <jaxb:globalBindings generateElementProperty="false"/> 
</jaxb:bindings> 
Run Code Online (Sandbox Code Playgroud)

据我所知,这与wsdl文档中的选择标签有关.

提前致谢

cxf jaxb webservice-client

3
推荐指数
1
解决办法
3291
查看次数

如何创建用于Web服务的密码摘要?

我正在尝试创建一个passwordDigest util,它可以在能够运行java字节代码的不同环境中使用.

首先,我创建了nonce.它是这样完成的.

public static String buildNonce(){
        StringBuffer nonce=new StringBuffer();
        String dateTimeString = Long.toString(new Date().getTime());
        byte[] nonceByte= dateTimeString.getBytes();
        return Base64.encode(nonceByte);
    }
Run Code Online (Sandbox Code Playgroud)

一旦我有了nonce,我就构建了密码摘要.

public static String buildPasswordDigest(String userName, String password, String nonce, String dateTime){
    MessageDigest sha1;
    String passwordDigest=null;
    try {
        sha1= MessageDigest.getInstance("SHA-1");
        byte[] hash = MessageDigest.getInstance("SHA-1").digest(password.getBytes("UTF-8"));
        sha1.update(nonce.getBytes("UTF-8"));
        sha1.update(dateTime.getBytes("UTF-8"));
        passwordDigest = new String(Base64.encode(sha1.digest(hash)));
        sha1.reset();
    } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return passwordDigest;
Run Code Online (Sandbox Code Playgroud)

为了测试一切正常.我使用CXF 2.7创建了一个测试Web服务.我手动创建了SOAP Envelope来测试身份验证.信封看起来像这样.

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                xmlns:ws="http://ws.mytest.org/" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance/">
    <soapenv:Header>
        <wsse:Security soapenv:mustUnderstand="1" 
          xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
          xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> …
Run Code Online (Sandbox Code Playgroud)

java authentication soap web-services webservice-client

3
推荐指数
1
解决办法
2万
查看次数