gpt4 book ai didi

调用 Java Web 服务时 C# 响应对象包含 null

转载 作者:行者123 更新时间:2023-11-30 12:00:27 27 4
gpt4 key购买 nike

我收到了以下 wsdl。我使用 wsdl.exe 生成了 C# 代理,还创建了我的 C# 网页。使用 Fiddler,我查看了 SOAP 响应,它包含数据。有关需要进行哪些修改以使 C# 程序接受 SOAP 响应的任何指导。请原谅 wsdl 的格式我不确定使用哪种格式以获得最佳结果。

WSDL

<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions xmlns:tns="https://wwf.web.spiritaero.com/tot/moves" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="CreateMoveHistory" targetNamespace="https://wwf.web.spiritaero.com/tot/moves" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<xsd:schema targetNamespace="https://wwf.web.spiritaero.com/tot/moves" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="CreateMoveHistoryResponse" type="tns:ReturnMessage" />
<xsd:element name="CreateMoveHistoryRequest" type="tns:CreateMoveHistoryContract" />
<xsd:complexType name="CreateMoveHistoryContract">
<xsd:sequence minOccurs="1" maxOccurs="1">
<xsd:element name="FromApplication" type="xsd:string" />
<xsd:element name="ActionName" type="xsd:string" />
<xsd:element name="OrderNumber" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="WorkCenter" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="Zone" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="Building" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="Floor" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="Post" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="SubCode" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="SubId" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="ScanDate" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="AntennaId" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="AntennaDescription" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="PartNumber" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CreateMoveHistoryFacade">
<xsd:sequence minOccurs="1" maxOccurs="1">
<xsd:element name="FromApplication" type="xsd:string" />
<xsd:element name="ActionName" type="xsd:string" />
<xsd:element name="OrderNumber" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="WorkCenter" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="Zone" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="Building" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="Floor" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="Post" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="SubCode" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="SubId" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="ScanDate" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="AntennaId" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="AntennaDescription" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="PartNumber" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="ReturnCode" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="ReturnMessage" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ReturnMessage">
<xsd:sequence minOccurs="1" maxOccurs="1">
<xsd:element name="Message" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="createMoveHistoryResponse">
<wsdl:part element="tns:CreateMoveHistoryResponse" name="createMoveHistoryResponse" />
</wsdl:message>
<wsdl:message name="createMoveHistoryRequest">
<wsdl:part element="tns:CreateMoveHistoryRequest" name="createMoveHistoryRequest" />
</wsdl:message>
<wsdl:portType name="CreateMoveHistoryPort">
<wsdl:operation name="createMoveHistory">
<wsdl:input message="tns:createMoveHistoryRequest" />
<wsdl:output message="tns:createMoveHistoryResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CreateMoveHistorySoap" type="tns:CreateMoveHistoryPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="createMoveHistory">
<soap:operation soapAction="https://wwf.web.spiritaero.com/tot/moves/CreateMoveHistory" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CreateMoveHistory">
<wsdl:port binding="tns:CreateMoveHistorySoap" name="CreateMoveHistory">
<soap:address location="http://pc790503.corp.spiritaero.com:8080/tot/moves?action=CreateMoveHistory" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

fiddler

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  
<soapenv:Header/>
<soapenv:Body>
<ReturnMessage xmlns="https://wwf.web.spiritaero.com/tot/moves">
<Message>Successful</Message>
</ReturnMessage>
</soapenv:Body>
</soapenv:Envelope>

为响应生成的 C# 代码

    [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="https://wwf.web.spiritaero.com/tot/moves")]
public partial class CreateMoveHistoryResponse {

private string messageField;

/// <remarks/>
public string Message {
get {
return this.messageField;
}
set {
this.messageField = value;
}
}
}

C#代码调用网络服务

CreateMoveHistory proxy;
CreateMoveHistoryRequest cmhRequest;
CreateMoveHistoryResponse msg;
....

msg = new CreateMoveHistoryResponse();
proxy = new CreateMoveHistory();
cmhRequest = new CreateMoveHistoryRequest();
cmhRequest.OrderNumber = "12345";
cmhRequest.Zone = "2";
cmhRequest.Building = "297F";
cmhRequest.Floor = "1";
cmhRequest.Post = "XX";
msg = proxy.createMoveHistory(cmhRequest);

问候,

D.富勒

最佳答案

如果您使用 WebReferences,请检查 wsdl 文件以确保 targetNamespace 和 namespace 相同。

希望对您有所帮助!

关于调用 Java Web 服务时 C# 响应对象包含 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1943180/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com