错误信息如下:
org.xml.sax.SAXException: Deserializing parameter 'result': could not find deserializer for type {http://wynner/xxx/ds/message/}GetX
org.xml.sax.SAXException: Deserializing parameter 'result': could not find deserializer for type {http://wynner/xxx/ds/message/}GetX
你的
call.addParameter("b1",qname,javax.xml.rpc.ParameterMode.IN);
call.addParameter("result",qname,javax.xml.rpc.ParameterMode.INOUT);
用同一个qname,qname是同webservice的发布相对应的,一个java参数对应消息中的一个qname我是入门级别,因此不要太相信.
GetX(BSTR b1,BSTR* result)的第二个参数是一个输出参数,参数类型为字符串
WSDL中的描述是类型描述是 xsd:string
另外,qname我不太明白你的意思,这些参数都是在同一名字空间下的.to junnef(光明圣堂武士):
你说的这些我都试过了,还是不行.
另外:
我用VC和VB又各写了一个客户端,其中VB的调用和返回都是成功的.
call.addParameter("b1",qname,javax.xml.rpc.ParameterMode.IN);
qname不是对应你的远程service的GetX方法的某个参数嘛?
将call.addParameter("result",qname,javax.xml.rpc.ParameterMode.INOUT);更改成QName serviceName = new QName("http://wynner/xxx/message/",yourservicename);
call.addParameter("result",serviceName,javax.xml.rpc.ParameterMode.INOUT);另外再说两句,你的service的方法的参数的名字是result,好像soap将函数的返回值默认的名字为result不知道这会不会导致冲突,不过你能够用其他客户端实现,说明你的
service没有问题,能贴出你用其他客户端测试成功后返回的soap消息吗?
public void addParameter(QName paramName,
QName xmlType,
ParameterMode parameterMode)Adds the specified parameter to the list of parameters for the operation associated with this Call object. Note: Not part of JAX-RPC specification. Parameters:
paramName - Name that will be used for the parameter in the XML
xmlType - XMLType of the parameter
parameterMode - one of IN, OUT or INOUT其中xmlType是参数的XMLType ,而不是操作方法的XMLType 吧,不知道我说的对不对
public void addParameter(QName paramName,
QName xmlType,
ParameterMode parameterMode)Adds the specified parameter to the list of parameters for the operation associated with this Call object. Note: Not part of JAX-RPC specification. Parameters:
paramName - Name that will be used for the parameter in the XML
xmlType - XMLType of the parameter
parameterMode - one of IN, OUT or INOUT其中xmlType是参数的XMLType ,而不是操作方法的XMLType 吧,不知道我说的对不对
QName qname = new QName(
"http://wynner/xxx/message/",
"GetX");
<definitions
name='SCT'
targetNamespace='http://wynner/SCT/wsdl/'
xmlns:wsdlns='http://wynner/SCT/wsdl/'
xmlns:typens='http://wynner/SCT/type/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:stk='http://schemas.microsoft.com/soap-toolkit/wsdl-extension'
xmlns:dime='http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/'
xmlns:ref='http://schemas.xmlsoap.org/ws/2002/04/reference/'
xmlns:content='http://schemas.xmlsoap.org/ws/2002/04/content-type/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'> <types>
<schema
targetNamespace='http://wynner/SCT/type/'
xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
elementFormDefault='qualified'> <import namespace='http://schemas.xmlsoap.org/soap/encoding/'/>
<import namespace='http://schemas.xmlsoap.org/wsdl/'/>
<import namespace='http://schemas.xmlsoap.org/ws/2002/04/reference/'/>
<import namespace='http://schemas.xmlsoap.org/ws/2002/04/content-type/'/> </schema>
</types> <message name='Speaker.GetMax'>
<part name='a' type='xsd:int'/>
<part name='b' type='xsd:int'/>
</message> <message name='Speaker.GetMaxResponse'>
<part name='result' type='xsd:int'/>
</message> <portType name='SpeakerSoapPort'> <operation name='GetMax' parameterOrder='a b result'>
<input message='wsdlns:Speaker.GetMax'/>
<output message='wsdlns:Speaker.GetMaxResponse'/>
</operation> </portType> <binding name='SpeakerSoapBinding' type='wsdlns:SpeakerSoapPort' > <stk:binding preferredEncoding='UTF-8'/>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/> <operation name='GetMax'>
<soap:operation soapAction='http://wynner/SCT/action/Speaker.GetMax'/>
<input>
<soap:body
use='encoded'
namespace='http://wynner/SCT/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
parts='a b'/>
</input>
<output>
<soap:body
use='encoded'
namespace='http://wynner/SCT/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
parts='result'/>
</output>
</operation> </binding> <service name='SCT' >
<port name='SpeakerSoapPort' binding='wsdlns:SpeakerSoapBinding' >
<soap:address location='http://wynner/sct/SCT.WSDL'/>
</port>
</service></definitions>
看你的wsdl文档的消息部分全都是xsd:int啊,我知道的不多,还是请高人指导吧.
com我不懂,二级指针我更不懂,如果能贴出你用vc调用返回的soap消息就很清楚了.
<?xml version='1.0' encoding='UTF-8' ?>
<definitions
name='SCT'
targetNamespace='http://wynner/SCT/wsdl/'
xmlns:wsdlns='http://wynner/SCT/wsdl/'
xmlns:typens='http://wynner/SCT/type/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:stk='http://schemas.microsoft.com/soap-toolkit/wsdl-extension'
xmlns:dime='http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/'
xmlns:ref='http://schemas.xmlsoap.org/ws/2002/04/reference/'
xmlns:content='http://schemas.xmlsoap.org/ws/2002/04/content-type/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'> <types>
<schema
targetNamespace='http://wynner/SCT/type/'
xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
elementFormDefault='qualified'> <import namespace='http://schemas.xmlsoap.org/soap/encoding/'/>
<import namespace='http://schemas.xmlsoap.org/wsdl/'/>
<import namespace='http://schemas.xmlsoap.org/ws/2002/04/reference/'/>
<import namespace='http://schemas.xmlsoap.org/ws/2002/04/content-type/'/> </schema>
</types> <message name='Speaker.GetMax'>
<part name='a' type='xsd:int'/>
<part name='b' type='xsd:int'/>
</message> <message name='Speaker.GetMaxResponse'>
<part name='rst' type='xsd:int'/>
</message> <message name='Speaker.GetInput'>
<part name='in' type='xsd:string'/>
</message> <message name='Speaker.GetInputResponse'>
<part name='out' type='xsd:string'/>
</message> <portType name='SpeakerSoapPort'> <operation name='GetMax' parameterOrder='a b rst'>
<input message='wsdlns:Speaker.GetMax'/>
<output message='wsdlns:Speaker.GetMaxResponse'/>
</operation> <operation name='GetInput' parameterOrder='in out'>
<input message='wsdlns:Speaker.GetInput'/>
<output message='wsdlns:Speaker.GetInputResponse'/>
</operation> </portType> <binding name='SpeakerSoapBinding' type='wsdlns:SpeakerSoapPort' > <stk:binding preferredEncoding='UTF-8'/>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/> <operation name='GetMax'>
<soap:operation soapAction='http://wynner/SCT/action/Speaker.GetMax'/>
<input>
<soap:body
use='encoded'
namespace='http://wynner/SCT/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
parts='a b'/>
</input>
<output>
<soap:body
use='encoded'
namespace='http://wynner/SCT/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
parts='rst'/>
</output>
</operation> <operation name='GetInput'>
<soap:operation soapAction='http://wynner/SCT/action/Speaker.GetInput'/>
<input>
<soap:body
use='encoded'
namespace='http://wynner/SCT/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
parts='in'/>
</input>
<output>
<soap:body
use='encoded'
namespace='http://wynner/SCT/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
parts='out'/>
</output>
</operation> </binding> <service name='SCT' >
<port name='SpeakerSoapPort' binding='wsdlns:SpeakerSoapBinding' >
<soap:address location='http://wynner/sct/SCT.WSDL'/>
</port>
</service></definitions>
很明显,调用成功了,但是就是取不到out的值HTTP/1.1 200 OKServer: Microsoft-IIS/5.0Date: Fri, 19 Sep 2003 01:02:31 GMTX-Powered-By: ASP.NETContent-Type: text/xml; charset="UTF-8"Content-Length: 367Expires: -1;<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAPSDK1:GetInputResponse xmlns:SOAPSDK1="http://wynner/SCT/message/"><out>abcdefg</out></SOAPSDK1:GetInputResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
http://expert.csdn.net/Expert/TopicView1.asp?id=2277435时也会出错
WSDL如下:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://generated.myservice.ws.bywang.com" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://generated.myservice.ws.bywang.com" xmlns:intf="http://generated.myservice.ws.bywang.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:message name="testStringHolderRequest"> <wsdl:part name="in0" type="xsd:string"/> <wsdl:part name="in1" type="xsd:string"/> </wsdl:message> <wsdl:message name="testStringHolderResponse"> <wsdl:part name="testStringHolderReturn" type="xsd:string"/> <wsdl:part name="in1" type="xsd:string"/> </wsdl:message> <wsdl:portType name="HolderTest"> <wsdl:operation name="testStringHolder" parameterOrder="in0 in1"> <wsdl:input message="impl:testStringHolderRequest" name="testStringHolderRequest"/> <wsdl:output message="impl:testStringHolderResponse" name="testStringHolderResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="testStringHolderSoapBinding" type="impl:HolderTest"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="testStringHolder"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="testStringHolderRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://generated.myservice.ws.bywang.com" use="encoded"/> </wsdl:input> <wsdl:output name="testStringHolderResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://generated.myservice.ws.bywang.com" use="encoded"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="HolderTestService"> <wsdl:port binding="impl:testStringHolderSoapBinding" name="testStringHolder"> <wsdlsoap:address location="http://localhost:8080/axis/services/testStringHolder"/> </wsdl:port> </wsdl:service></wsdl:definitions>
package com.bywang.app;import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.encoding.*;
import javax.xml.namespace.QName;
import java.util.*;
import com.bywang.ws.holders.*;
import org.apache.axis.*;
import org.apache.axis.components.logger.LogFactory;
import org.apache.axis.encoding.Base64;
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.transport.http.HTTPConstants;
import org.apache.axis.utils.Messages;
import org.apache.axis.message.*;
//import javax.xml.soap.*;
import java.util.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import org.apache.commons.logging.Log;/**
* This class illustrates how to use the JAX-RPC API to invoke
* the Order Processing Web service dynamically
*/
public class testStringHolderClient {
public static void main(String[] args) throws Exception {
String targetNamespace = "http://generated.myservice.ws.bywang.com";
Service service = new Service(); Call call = (Call) service.createCall();
call.setTargetEndpointAddress("http://localhost:8080/axis/services/testStringHolder");
QName qnstrIn=new QName(targetNamespace,"in0");
QName qnstrInOut=new QName(targetNamespace,"in1");
QName operationName = new QName(targetNamespace, "testStringHolder"); call.setOperationName(operationName);
QName serviceName = new QName(targetNamespace,
"testStringHolder"); call.addParameter("strh",serviceName,ParameterMode.INOUT); call.setReturnType( XMLType.XSD_STRING );
String test=new String("send a test string ");
String inoutStr=new String("send a inout string");
String str=(String)call.invoke( new Object[] {inoutStr} );
System.out.println(str);
Map outparams = call.getOutputParams();
if (outparams!=null)
{
Iterator ite=outparams.values().iterator();
if (ite.hasNext())
{
System.out.println((String)ite.next());
}
}
}
}
原来要把INOUT换成IN !!???
简直是太莫名奇妙了!