我在.NET项目中使用AXIS服务参考时遇到了一些问题。我今天简单地在VS2010中添加了引用,但是提供的Method都没有返回Type或Params。我只是看了生成的WSDL,它看起来像这样:(简短的这个Schema,也许缺少一些消息元素,但让我们关注参数的东西)
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:intf="urn:api.broadmail.de/soap11/RpcSession" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns2="http://lang.java" xmlns:impl="urn:api.broadmail.de/soap11/RpcSession" targetNamespace="urn:api.broadmail.de/soap11/RpcSession" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:api.broadmail.de/soap11/RpcSession">
<xsd:import namespace="http://lang.java" />
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:complexType name="WebserviceException">
<xsd:sequence>
<xsd:element name="cause" nillable="true" type="xsd:anyType" />
<xsd:element name="message" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="loginRequest">
<wsdl:part name="in0" type="xsd:long" />
<wsdl:part name="in1" type="xsd:string" />
<wsdl:part name="in2" type="xsd:string" />
</wsdl:message>
<wsdl:portType name="SessionWebservice">
<wsdl:operation name="login" parameterOrder="in0 in1 in2">
<wsdl:input name="loginRequest" message="impl:loginRequest" />
<wsdl:output name="loginResponse" message="impl:loginResponse" />
<wsdl:fault name="WebserviceException" message="impl:WebserviceException" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="RpcSessionSoapBinding" type="impl:SessionWebservice">
<wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
<wsdl:operation name="login">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="loginRequest">
<wsdlsoap:body use="encoded" namespace="urn:api.broadmail.de/soap11/RpcSession" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:input>
<wsdl:output name="loginResponse">
<wsdlsoap:body use="encoded" namespace="urn:api.broadmail.de/soap11/RpcSession" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:output>
<wsdl:fault name="WebserviceException">
<wsdlsoap:fault use="encoded" name="WebserviceException" namespace="urn:api.broadmail.de/soap11/RpcSession" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SessionWebserviceService">
<wsdl:port name="RpcSession" binding="impl:RpcSessionSoapBinding">
<wsdlsoap:address location="https://api.broadmail.de/soap11/RpcSession" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
之后我查看了我生成的代理类“reference.cs”,通知方法中没有参数。
namespace OptivoInterfaceApp.broadmailSession {
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="urn:api.broadmail.de/soap11/RpcSession", ConfigurationName="broadmailSession.SessionWebservice")]
public interface SessionWebservice {
[System.ServiceModel.OperationContractAttribute()]
void login();
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface SessionWebserviceChannel : OptivoInterfaceApp.broadmailSession.SessionWebservice, System.ServiceModel.IClientChannel {
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class SessionWebserviceClient : System.ServiceModel.ClientBase<OptivoInterfaceApp.broadmailSession.SessionWebservice>, OptivoInterfaceApp.broadmailSession.SessionWebservice {
public SessionWebserviceClient() {
}
public SessionWebserviceClient(string endpointConfigurationName) :
base(endpointConfigurationName) {
}
public SessionWebserviceClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public SessionWebserviceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public SessionWebserviceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress) {
}
public void login() {
base.Channel.login();
}
}
}
我是否必须手动将params添加到我的代理类中,或者我还有其他错误吗?我只是尝试手动添加参数,但在方法调用上我只得到一个异常。
我的任何提示?
答案 0 :(得分:0)
也许你应该使用WRAPPED风格。
更多信息:http://axis.apache.org/axis/java/user-guide.html#ServiceStylesRPCDocumentWrappedAndMessage