需要wsdl更正,使用Axis 1.3反序列化的空输出
本文关键字:反序列化 输出 Axis wsdl 更正 使用 需要 | 更新日期: 2023-09-27 18:09:29
在工作中遇到麻烦。我需要在c#中正确地集成外部Axis 1.3 web服务。我意识到空输出问题,我花了两天时间在这里遵循几个建议,并在wsdl中使用名称空间和参数,试图使其正确反序列化。Servise是一个简单的方法,它使用一个字符串作为输入,并在输出中返回另一个字符串,因此没有复杂的元素。这是其他开发人员提供的wsdl(出于隐私原因,我将原始地址替换为TEMP)
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://TEMP.it:9080/FATCAKYC/axis/CallQuestionarioFatcaCompletoNoXml"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://TEMP.it:9080/FATCAKYC/axis/CallQuestionarioFatcaCompletoNoXml"
xmlns:intf="http://TEMP.it:9080/FATCAKYC/axis/CallQuestionarioFatcaCompletoNoXml"
xmlns:tns1="http://integration.ws.it"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.3
Built on Oct 05, 2005 (05:23:37 EDT)-->
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://integration.ws.it"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="input" type="xsd:string"/>
</schema>
<schema elementFormDefault="qualified" targetNamespace="http://TEMP.it:9080/FATCAKYC/axis/CallQuestionarioFatcaCompletoNoXml"
xmlns="http://www.w3.org/2001/XMLSchema" >
<element name="inputReturn" type="xsd:string"/>
</schema>
</wsdl:types>
<wsdl:message name="getQuestionarioFatcaCompletoNoXMLRequest">
<wsdl:part element="tns1:input" name="input">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getQuestionarioFatcaCompletoNoXMLResponse">
<wsdl:part element="intf:inputReturn" name="inputReturn">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="WsIntegrationFatcaCompletoNoXml">
<wsdl:operation name="getQuestionarioFatcaCompletoNoXML">
<wsdl:input message="impl:getQuestionarioFatcaCompletoNoXMLRequest" name="getQuestionarioFatcaCompletoNoXMLRequest">
</wsdl:input>
<wsdl:output message="impl:getQuestionarioFatcaCompletoNoXMLResponse" name="getQuestionarioFatcaCompletoNoXMLResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CallQuestionarioFatcaCompletoNoXmlSoapBinding" type="impl:WsIntegrationFatcaCompletoNoXml">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getQuestionarioFatcaCompletoNoXML">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getQuestionarioFatcaCompletoNoXMLRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getQuestionarioFatcaCompletoNoXMLResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WsIntegrationFatcaCompletoNoXmlService">
<wsdl:port binding="impl:CallQuestionarioFatcaCompletoNoXmlSoapBinding" name="CallQuestionarioFatcaCompletoNoXml">
<wsdlsoap:address location="http://TEMP.it:9080/FATCAKYC/axis/CallQuestionarioFatcaCompletoNoXml"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
这个类是由visual studio自动生成的
namespace BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto {
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://TEMP.it:9080/FATCAKYC/axis/CallQuestionarioFatcaComp" +
"letoNoXml", ConfigurationName="CallQuestionarioFatcaCompleto.WsIntegrationFatcaCompletoNoXml")]
public interface WsIntegrationFatcaCompletoNoXml {
// CODEGEN: Generating message contract since the operation getQuestionarioFatcaCompletoNoXML is neither RPC nor document wrapped.
[System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto.getQuestionarioFatcaCompletoNoXMLResponse getQuestionarioFatcaCompletoNoXML(BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto.getQuestionarioFatcaCompletoNoXMLRequest request);
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial class getQuestionarioFatcaCompletoNoXMLRequest {
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://integration.ws.it", Order=0)]
public string input;
public getQuestionarioFatcaCompletoNoXMLRequest() {
}
public getQuestionarioFatcaCompletoNoXMLRequest(string input) {
this.input = input;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial class getQuestionarioFatcaCompletoNoXMLResponse {
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://TEMP.it:9080/FATCAKYC/axis/CallQuestionarioFatcaComp" +
"letoNoXml", Order=0)]
public string inputReturn;
public getQuestionarioFatcaCompletoNoXMLResponse() {
}
public getQuestionarioFatcaCompletoNoXMLResponse(string inputReturn) {
this.inputReturn = inputReturn;
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public interface WsIntegrationFatcaCompletoNoXmlChannel : BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto.WsIntegrationFatcaCompletoNoXml, System.ServiceModel.IClientChannel {
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public partial class WsIntegrationFatcaCompletoNoXmlClient : System.ServiceModel.ClientBase<BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto.WsIntegrationFatcaCompletoNoXml>, BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto.WsIntegrationFatcaCompletoNoXml {
public WsIntegrationFatcaCompletoNoXmlClient() {
}
public WsIntegrationFatcaCompletoNoXmlClient(string endpointConfigurationName) :
base(endpointConfigurationName) {
}
public WsIntegrationFatcaCompletoNoXmlClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public WsIntegrationFatcaCompletoNoXmlClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public WsIntegrationFatcaCompletoNoXmlClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress) {
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto.getQuestionarioFatcaCompletoNoXMLResponse BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto.WsIntegrationFatcaCompletoNoXml.getQuestionarioFatcaCompletoNoXML(BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto.getQuestionarioFatcaCompletoNoXMLRequest request) {
return base.Channel.getQuestionarioFatcaCompletoNoXML(request);
}
public string getQuestionarioFatcaCompletoNoXML(string input) {
BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto.getQuestionarioFatcaCompletoNoXMLRequest inValue = new BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto.getQuestionarioFatcaCompletoNoXMLRequest();
inValue.input = input;
BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto.getQuestionarioFatcaCompletoNoXMLResponse retVal = ((BizTier.Application.FATCAQuestionnaire.CallQuestionarioFatcaCompleto.WsIntegrationFatcaCompletoNoXml)(this)).getQuestionarioFatcaCompletoNoXML(inValue);
return retVal.inputReturn;
}
}
}
这是一个输入soap示例
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://integration.ws.it">
<soapenv:Header/>
<soapenv:Body>
<int:input> example input string </int:input>
</soapenv:Body>
</soapenv:Envelope>
这是一个输出soap示例
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<inputReturn xmlns="http://integration.ws.it">example string output
</inputReturn>
</soapenv:Body>
</soapenv:Envelope>
我需要改变什么使它工作?我尝试强制输入输出名称空间"http://integration.ws"。它"或从参数中删除命名空间,但运气不好。
还有其他建议吗?
由peer解决
服务参考不行,这种服务需要web参考
生成的代码有这一行[return: System.Xml.Serialization.XmlElementAttribute("getQuestionarioFatcaCompletoNoXMLReturn", Namespace="http://TEMP.it:9080/FATCAKYC/axis/CallQuestionarioFatcaCompletoNoXml")]
只是将参数和名称空间替换为输出soap响应中的参数和名称空间,我最终得到了正确反序列化的输出
[return: System.Xml.Serialization.XmlElementAttribute("inputReturn", Namespace = "http://integration.ws.it")]
我的预感是对的,但我只是使用了错误的引用