веб-сервис, написанный на Java проблема с C# веб-сервисом - PullRequest
0 голосов
/ 19 июня 2020

Я новичок в C#, и я создал веб-сервис в C#, используя asmx проекта веб-сайта / веб-сервиса в C#.

[WebService(Namespace = "http://bla.ws.com/", Name = "SMP034")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class ReceivePayment : WebService
{
    [WebMethod]
    [return: XmlElement("accept")]
    [SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Wrapped)]
    public accept receivePayment(payment payment)
    {
        accept ac = new accept();
        .... some task.....
        return ac;
    }


    [WebMethod]
    [return: XmlElement("confirm")]
    [SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Wrapped)]
    public confirm receivePaymentConfirm(payment payment)
    {
        confirm co = new confirm();
        .... some task ....
        return co;
    }
}

, это дает мне WSDL:

<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://bla.ws.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://bla.ws.com/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://bla.ws.com/">
<s:element name="receivePayment">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="payment" type="tns:payment"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="payment">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" form="unqualified" name="confirm" type="tns:confirm"/>
<s:element minOccurs="0" maxOccurs="1" form="unqualified" name="syssmp" type="tns:syssmp"/>
<s:element minOccurs="0" maxOccurs="1" form="unqualified" name="payer" type="tns:payer"/>
<s:element minOccurs="0" maxOccurs="1" form="unqualified" name="payee" type="tns:payee"/>
<s:element minOccurs="0" maxOccurs="1" form="unqualified" name="purpose" type="tns:purpose"/>
<s:element minOccurs="0" maxOccurs="1" form="unqualified" name="amount" type="tns:amount"/>
<s:element minOccurs="0" maxOccurs="1" form="unqualified" name="document" type="tns:document"/>
<s:element minOccurs="0" maxOccurs="1" form="unqualified" name="budget" type="tns:budget"/>
<s:element minOccurs="0" maxOccurs="1" form="unqualified" name="dsign" type="s:string"/>
</s:sequence>
</s:complexType>
<s:complexType name="confirm">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="code" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="message" type="s:string"/>
</s:sequence>
</s:complexType>
<s:complexType name="syssmp">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="init_data" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="init_time" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="pay_data" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="pay_time" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="bid" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="sid" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="rid" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="tid" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="session" type="s:string"/>
</s:sequence>
</s:complexType>
<s:complexType name="payer">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="branch" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="account" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="name" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="inn" type="s:string"/>
</s:sequence>
</s:complexType>
<s:complexType name="payee">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="branch" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="account" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="name" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="inn" type="s:string"/>
</s:sequence>
</s:complexType>
<s:complexType name="purpose">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="code" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="text" type="s:string"/>
</s:sequence>
</s:complexType>
<s:complexType name="amount">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="currency" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="value" type="s:string"/>
</s:sequence>
</s:complexType>
<s:complexType name="document">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="doc_n" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="doc_d" type="s:string"/>
</s:sequence>
</s:complexType>
<s:complexType name="budget">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="budget_income" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="budget_account" type="s:string"/>
</s:sequence>
</s:complexType>
<s:element name="receivePaymentResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="accept" type="tns:accept"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="accept">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="affirm" type="tns:affirm"/>
<s:element minOccurs="0" maxOccurs="1" name="dsign" type="s:string"/>
</s:sequence>
</s:complexType>
<s:complexType name="affirm">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="confirm" type="tns:confirm"/>
<s:element minOccurs="0" maxOccurs="1" name="statement" type="tns:statement"/>
</s:sequence>
</s:complexType>
<s:complexType name="statement">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="id" type="s:string"/>
</s:sequence>
</s:complexType>
<s:element name="receivePaymentConfirm">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="payment" type="tns:payment"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="receivePaymentConfirmResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="confirm" type="tns:confirm"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="receivePaymentSoapIn">
<wsdl:part name="parameters" element="tns:receivePayment"/>
</wsdl:message>
<wsdl:message name="receivePaymentSoapOut">
<wsdl:part name="parameters" element="tns:receivePaymentResponse"/>
</wsdl:message>
<wsdl:message name="receivePaymentConfirmSoapIn">
<wsdl:part name="parameters" element="tns:receivePaymentConfirm"/>
</wsdl:message>
<wsdl:message name="receivePaymentConfirmSoapOut">
<wsdl:part name="parameters" element="tns:receivePaymentConfirmResponse"/>
</wsdl:message>
<wsdl:portType name="SMP034Soap">
<wsdl:operation name="receivePayment">
<wsdl:input message="tns:receivePaymentSoapIn"/>
<wsdl:output message="tns:receivePaymentSoapOut"/>
</wsdl:operation>
<wsdl:operation name="receivePaymentConfirm">
<wsdl:input message="tns:receivePaymentConfirmSoapIn"/>
<wsdl:output message="tns:receivePaymentConfirmSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SMP034Soap" type="tns:SMP034Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="receivePayment">
<soap:operation soapAction="http://bla.ws.com/receivePayment" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="receivePaymentConfirm">
<soap:operation soapAction="http://bla.ws.com/receivePaymentConfirm" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="SMP034Soap12" type="tns:SMP034Soap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="receivePayment">
<soap12:operation soapAction="http://bla.ws.com/receivePayment" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="receivePaymentConfirm">
<soap12:operation soapAction="http://bla.ws.com/receivePaymentConfirm" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SMP034">
<wsdl:port name="SMP034Soap" binding="tns:SMP034Soap">
<soap:address location="http://1.1.1.1/anor/services/wsSMP034/ReceivePayment.asmx"/>
</wsdl:port>
<wsdl:port name="SMP034Soap12" binding="tns:SMP034Soap12">
<soap12:address location="http://1.1.1.1/anor/services/wsSMP034/ReceivePayment.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Определение проблемы:

Когда другие вызывают эту веб-службу [receivePayment], они получают ошибку:

javax. xml .ws.WebServiceException: class com .ws.bla.ReceivePayment не имеют свойства имени {http://bla.ws.com/} платежа

Они реализованы в Java для вызова нашего веб-сервиса

Если я реализую это в Java, все будет нормально. ниже WSDL Java реализации моего веб-сервиса

<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://bla.ws.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://bla.ws.com/" name="wsSMP034">
<types>
<xs:schema xmlns:tns="http://bla.ws.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://bla.ws.com/">
<xs:element name="receivePayment" type="tns:receivePayment"/>
<xs:element name="receivePaymentConfirm" type="tns:receivePaymentConfirm"/>
<xs:element name="receivePaymentConfirmResponse" type="tns:receivePaymentConfirmResponse"/>
<xs:element name="receivePaymentResponse" type="tns:receivePaymentResponse"/>
<xs:complexType name="receivePaymentConfirm">
<xs:sequence>
<xs:element name="payment" type="tns:payment" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="payment">
<xs:sequence>
<xs:element name="confirm" type="tns:confirm"/>
<xs:element name="syssmp" type="tns:syssmp"/>
<xs:element name="payer" type="tns:payer"/>
<xs:element name="payee" type="tns:payee"/>
<xs:element name="purpose" type="tns:purpose"/>
<xs:element name="amount" type="tns:amount"/>
<xs:element name="document" type="tns:document"/>
<xs:element name="budget" type="tns:budget"/>
<xs:element name="dsign" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="confirm">
<xs:sequence>
<xs:element name="code" type="xs:string"/>
<xs:element name="message" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="syssmp">
<xs:sequence>
<xs:element name="init_data" type="xs:string"/>
<xs:element name="init_time" type="xs:string"/>
<xs:element name="pay_data" type="xs:string"/>
<xs:element name="pay_time" type="xs:string"/>
<xs:element name="bid" type="xs:string"/>
<xs:element name="sid" type="xs:string"/>
<xs:element name="rid" type="xs:string"/>
<xs:element name="tid" type="xs:string"/>
<xs:element name="session" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="payer">
<xs:sequence>
<xs:element name="branch" type="xs:string"/>
<xs:element name="account" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="inn" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="payee">
<xs:sequence>
<xs:element name="branch" type="xs:string"/>
<xs:element name="account" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="inn" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="purpose">
<xs:sequence>
<xs:element name="code" type="xs:string"/>
<xs:element name="text" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="amount">
<xs:sequence>
<xs:element name="currency" type="xs:string"/>
<xs:element name="value" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="document">
<xs:sequence>
<xs:element name="doc_n" type="xs:string"/>
<xs:element name="doc_d" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="budget">
<xs:sequence>
<xs:element name="budget_income" type="xs:string"/>
<xs:element name="budget_account" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="receivePaymentConfirmResponse">
<xs:sequence>
<xs:element name="return" type="tns:confirm" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="receivePayment">
<xs:sequence>
<xs:element name="payment" type="tns:payment" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="receivePaymentResponse">
<xs:sequence>
<xs:element name="return" type="tns:accept" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="accept">
<xs:sequence>
<xs:element name="affirm" type="tns:affirm"/>
<xs:element name="dsign" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="affirm">
<xs:sequence>
<xs:element name="confirm" type="tns:confirm"/>
<xs:element name="statement" type="tns:statement"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="statement">
<xs:sequence>
<xs:element name="id" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
<message name="receivePayment">
<part name="parameters" element="tns:receivePayment"/>
</message>
<message name="receivePaymentResponse">
<part name="parameters" element="tns:receivePaymentResponse"/>
</message>
<message name="receivePaymentConfirm">
<part name="parameters" element="tns:receivePaymentConfirm"/>
</message>
<message name="receivePaymentConfirmResponse">
<part name="parameters" element="tns:receivePaymentConfirmResponse"/>
</message>
<portType name="ws">
<operation name="receivePayment">
<input message="tns:receivePayment"/>
<output message="tns:receivePaymentResponse"/>
</operation>
<operation name="receivePaymentConfirm">
<input message="tns:receivePaymentConfirm"/>
<output message="tns:receivePaymentConfirmResponse"/>
</operation>
</portType>
<binding name="wsSMP034Binding" type="tns:ws">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="receivePayment">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="receivePaymentConfirm">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="wsSMP034">
<port name="wsSMP034" binding="tns:wsSMP034Binding">
<soap:address location="http://1.1.1.1:80/SMPNNNWebService/aaaaaaa"/>
</port>
</service>
</definitions>

Вопрос:

Что я делаю неправильно в C#?

Что нужно изменить в моем C#, чтобы он работал как в Java?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...