WebService의 WSDL을 건네주었습니다. 구현해야하고 기본 구조를 생성해야합니다 (.NET SDK의 svcutils.exe와 Visual Studio의 WSDL.blue 플러그인 모두 사용). 누군가는이 WebService를 소비 할 것이고, 그들이하는 요청 유형을 변경할 수는 없습니다. 여기 내 클라이언트에서 캡처 한 샘플 SOAP 요청의 :C# WebService의 Null 매개 변수
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<env:Header></env:Header>
<env:Body>
<ns1:setNetworkActivatorResponse xmlns:ns1='http://client.response.ws.meh/'>
<OrderResponse>
<orderHeader>
<clientID>trD-125205</clientID>
<description>0</description>
<operation>trD</operation>
<orderKey>
<applicationContext>
<URL>http://xxx.xxx.xxx.xxx:8181/</URL>
<hostName>xxx.xxx.xxx.xxx</hostName>
</applicationContext>
<applicationDN>XYPT</applicationDN>
<primaryKey>170809</primaryKey>
</orderKey>
<priority>1</priority>
</orderHeader>
<info>
Yadda Yadda Yadda text.
</info>
</OrderResponse>
</ns1:setNetworkActivatorResponse>
</env:Body>
</env:Envelope>
이 요청은 (setNetworkActivatorResponse()), 그러나 방법의 매개 변수 OrderResponse이 널 (null)로 전달되는 웹 서버의 오른쪽 메소드를 호출합니다. 그 요청을 수정하고 OrderResponse (예 : <ns1:OrderResponse> </ns1:OrderResponse>
)에 ns1 네임 스페이스를 추가하면 매개 변수가 올바르게 전달되고 OrderResponse 개체를 C# 메서드에서 사용할 수 있으므로 네임 스페이스와 관련이 있다고 생각합니다.
내 방법은 일반적인 C# .NET을 WebService를 다음과 같이 정의된다
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.233")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://client.response.ws.na.agorang.ptinovacao.pt/")]
public partial class OrderResponse
{
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string messageID;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public OrderHeader orderHeader;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string info;
}
필요한 클래스 (OrderResponse 등) 정의로 구현됩니다 :
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[WebService(Namespace = "http://client.response.ws.meh/")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://client.response.ws.meh/")]
[System.ServiceModel.ServiceContractAttribute(Namespace = "http://client.response.ws.meh/", ConfigurationName = "ResponseClientWebService")]
public class ResponseClientWebService : System.Web.Services.WebService
{
[WebMethod]
public void setNetworkActivatorResponse(OrderResponse OrderResponse)
{
String meh = OrderResponse.info;
}
}
그리고 여기 내 OrderResponse 클래스입니다 잘. 어떤 코드를 (SOAP 요청을 받아 들일 수 있도록하기 위해 클라이언트의 요청을 OrderResponse에 대한 ns1 네임 스페이스를 변경할 수 없으므로) 어떻게 변경할 수 있습니까? 감사합니다.
'OrderResponse' 클래스의 정의를 보여줄 수 있습니까? – pmartin
물론 원본 본문에 추가했습니다. –