soapCall.setTargetObjectURI("");
这里面的参数具体是什么啊,看了好长时间也没看明白。
那位高手指教一下。

解决方案 »

  1.   

    不知道你用的是什么,xfire还是?
      

  2.   

    服务用的是cxf,读取用的是soap.
      

  3.   

    call.setTargetObjectURI("urn:cd-catalog");其中的urn就是你要在服务器上面部署的webservice。urn:cd-catalog
    urn:AddressFetcher
    urn:xml-soap-demo-calculator
      

  4.   

    <wsdl:definitions name="HelloWorldImplService" targetNamespace="http://gerun.com/" xmlns:ns1="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://gerun.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    urn是固定的,还是写成服务名字。
    我的webservice的名字是HelloWorldImplService,类的名字叫HelloWorld。这里是不是写成
    call.setTargetObjectURI("HelloWorldImplService:HelloWorld");
      

  5.   

    访问的时候,一直报下面这个错误。
    警告: Interceptor for {http://gerun.com/}HelloWorldImplService#{http://gerun.com/}sayHello has thrown exception, unwinding now
    org.apache.cxf.interceptor.Fault: Unexpected wrapper element {testwebservice2:HelloWorld}sayHello found.   Expected {http://gerun.com/}sayHello.
      

  6.   

    call.setTargetObjectURI("<你部署的webservice>");确定你已经部署了这个webservice在的服务器。
      

  7.   

    Unexpected wrapper element {testwebservice2:HelloWorld}sayHello found. Expected {http://gerun.com/}sayHello.
      

  8.   

    我用apache-cxf-2.2.9的方式布署的。spring加载的。
    bean.xml文件是
    <?xml version="1.0" encoding="UTF-8"?>  
    <beans xmlns="http://www.springframework.org/schema/beans"  
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xmlns:jaxws="http://cxf.apache.org/jaxws"  
        xsi:schemaLocation="http://www.springframework.org/schema/beans    
        http://www.springframework.org/schema/beans/spring-beans.xsd   
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">  
      
        <import resource="classpath:META-INF/cxf/cxf.xml" />
        <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />  
        <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />  
      
        <jaxws:endpoint id="HelloWorld" implementor="com.gerun.HelloWorldImpl" address="/HelloWorld" />  
    </beans>
    两个类很简单就是一个sayHello()方法,里面打出一个字符串。访问这个地址http://localhost:8080/testwebservice2/HelloWorld?wsdl
    得到下面的wsdl
    <?xml version="1.0" encoding="UTF-8" ?> 
    - <wsdl:definitions name="HelloWorldImplService" targetNamespace="http://gerun.com/" xmlns:ns1="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://gerun.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    - <wsdl:types>
    - <xs:schema elementFormDefault="unqualified" targetNamespace="http://gerun.com/" version="1.0" xmlns:tns="http://gerun.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="sayHello" type="tns:sayHello" /> 
      <xs:element name="sayHelloResponse" type="tns:sayHelloResponse" /> 
    - <xs:complexType name="sayHello">
      <xs:sequence /> 
      </xs:complexType>
    - <xs:complexType name="sayHelloResponse">
    - <xs:sequence>
      <xs:element minOccurs="0" name="return" type="xs:string" /> 
      </xs:sequence>
      </xs:complexType>
      </xs:schema>
      </wsdl:types>
    - <wsdl:message name="sayHelloResponse">
      <wsdl:part element="tns:sayHelloResponse" name="parameters" /> 
      </wsdl:message>
    - <wsdl:message name="sayHello">
      <wsdl:part element="tns:sayHello" name="parameters" /> 
      </wsdl:message>
    - <wsdl:portType name="HelloWorld">
    - <wsdl:operation name="sayHello">
      <wsdl:input message="tns:sayHello" name="sayHello" /> 
      <wsdl:output message="tns:sayHelloResponse" name="sayHelloResponse" /> 
      </wsdl:operation>
      </wsdl:portType>
    - <wsdl:binding name="HelloWorldImplServiceSoapBinding" type="tns:HelloWorld">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
    - <wsdl:operation name="sayHello">
      <soap:operation soapAction="" style="document" /> 
    - <wsdl:input name="sayHello">
      <soap:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output name="sayHelloResponse">
      <soap:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
    - <wsdl:service name="HelloWorldImplService">
    - <wsdl:port binding="tns:HelloWorldImplServiceSoapBinding" name="HelloWorldImplPort">
      <soap:address location="http://localhost:8080/testwebservice2/HelloWorld" /> 
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>访问http://localhost:8080/testwebservice2
    得到
    Available SOAP services:
    HelloWorld
    •sayHello
                 Endpoint address: http://localhost:8080/testwebservice2/HelloWorld
                 WSDL : {http://gerun.com/}HelloWorldImplService
                 Target namespace: http://gerun.com/ 
      

  9.   

    <wsdl:definitions name="HelloWorldImplService" targetNamespace="http://gerun.com/" xmlns:ns1="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://gerun.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">根据错误信息
    Unexpected wrapper element {testwebservice2:HelloWorld}sayHello found.  
    Expected {http://gerun.com/}sayHello.尝试改一下 
    targetNamespace="testwebservice2"
      

  10.   

    我现在是用axi的客户端是可以成功调用 的。
    但用soap客户总不能成功。
      

  11.   

    Service service = new Service();
    System.out.println("bbbbbbbbb");
    try{
    Call call=(Call)service.createCall();
    System.out.println("dddddddd");
    call.setTargetEndpointAddress(new java.net.URL("http://localhost:8080/testwebservice2/HelloWorld"));
    System.out.println("cccccccccc");
    call.setEncodingStyle(Constants.NS_PREFIX_SOAP_ENV);
    call.setOperationName(new QName("http://gerun.com/","sayHello"));
    //call.setReturnType(org.apache.axis.Constants.XSD_STRING);
    Object obj=call.invoke(new Object[]{});
    System.out.println(obj.toString());
    System.out.println(call.getTargetEndpointAddress());
    return ;
    }catch(Exception e){

    }
      

  12.   

    thanks for your responses.i did figure out the problem and fix it.
    I turns out I do have to deserialize the return by adding this code to the class that invokes the web service:
    SOAPMappingRegistry smr = new SOAPMappingRegistry();
    StringDeserializer sd = new StringDeserializer ();
    smr.mapTypes (Constants.NS_URI_SOAP_ENC, new QName ("", "return"), null, null, sd);
    call.setSOAPMappingRegistry(smr);
    It has to do with the xsi:type, which is seen as "the most common interop problem." The Apache soap puts the xsi:type elements for all parameters in the request. But, the xsi:type is missing in the response, which includes result or return.
    When the xsi:type attribute of the result or return element is missing, the error message will say "SOA-ENV:Client;No deserialization found....."
    The solution is to add code to deserialize the return.
    The xsi:type problem does not show up when I run the application within WSAD 4.1.1. It only shows up when I run the client outside it.
    I hope this will help others to solve the deserialization problem on the client side. If it happens on the server side, you'll need to add the deserialization stuff in the deployment descriptor.
    Thanks for your help. You ranchers are a bunch of great guys.
    Thanks.