Ошибка HTTP 415 при публикации из SOAPClient в REST

Мне нужно сделать успешный запрос к веб-сервису REST от очень старого Soap Client.

Веб-сервис принимает эти запросы:

public class FunctionsResource {
@Context
private UriInfo context;

/** Creates a new instance of FunctionsResource */
public FunctionsResource() {
}

@GET
@Produces("application/xml")
public String handleGet(@PathParam("functionName") String   functionName) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException{

    return RestfulTools.handleGet(Dummy.class, functionName, context.getQueryParameters());

 }
@POST
@Consumes("application/x-www-form-urlencoded")
@Produces("application/xml")
public String handlePost(@PathParam("functionName") String functionName, MultivaluedMap<String, String> formParams) throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException{
    return RestfulTools.handlePost(Dummy.class, functionName, formParams);
}
}

При выполнении запросов из старого кода C# (который я НЕ должен немного его изменять) я продолжаю получать base {System.InvalidOperationException} = {"Запрос не выполнен с HTTP-статусом 415: Unsupported Media Type."}.

Трассировки стека:

"at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse (сообщение SoapClientMessage, ответ WebResponse, поток responseStream, логический asyncCall)\r\n в System.Web.Services.Protocols.SoapHttpClientProjectIn.) \ r \ n в Entegrasyon.GetOriginator.GetOriginators.getOriginators(String xml) в C:\Users\Administrator\Downloads\ Новая папка \c_ornek\Entegrasyon\ Веб-ссылки \GetOriginator\Reference.cs: строка 78\r\n в Entegrasyon.Form1.button1_Click(Отправитель объекта, EventArgs e) в C:\Users\Administrator\Downloads\ Новая папка \c_ornek\Entegrasyon\Form1.cs: строка 70"

Это WSDL этого клиента.

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions 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:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
      <s:element name="getOriginators">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="xml" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="getOriginatorsResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="getOriginatorsResult" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="string" nillable="true" type="s:string" />
    </s:schema>
  </wsdl:types>
  <wsdl:message name="getOriginatorsSoapIn">
    <wsdl:part name="parameters" element="tns:getOriginators" />
  </wsdl:message>
  <wsdl:message name="getOriginatorsSoapOut">
    <wsdl:part name="parameters" element="tns:getOriginatorsResponse" />
  </wsdl:message>
  <wsdl:message name="getOriginatorsHttpGetIn">
    <wsdl:part name="xml" type="s:string" />
  </wsdl:message>
  <wsdl:message name="getOriginatorsHttpGetOut">
    <wsdl:part name="Body" element="tns:string" />
  </wsdl:message>
  <wsdl:message name="getOriginatorsHttpPostIn">
    <wsdl:part name="xml" type="s:string" />
  </wsdl:message>
  <wsdl:message name="getOriginatorsHttpPostOut">
    <wsdl:part name="Body" element="tns:string" />
  </wsdl:message>
  <wsdl:portType name="GetOriginatorsSoap">
    <wsdl:operation name="getOriginators">
      <wsdl:input message="tns:getOriginatorsSoapIn" />
      <wsdl:output message="tns:getOriginatorsSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:portType name="GetOriginatorsHttpGet">
    <wsdl:operation name="getOriginators">
      <wsdl:input message="tns:getOriginatorsHttpGetIn" />
      <wsdl:output message="tns:getOriginatorsHttpGetOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:portType name="GetOriginatorsHttpPost">
    <wsdl:operation name="getOriginators">
      <wsdl:input message="tns:getOriginatorsHttpPostIn" />
      <wsdl:output message="tns:getOriginatorsHttpPostOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="GetOriginatorsSoap" type="tns:GetOriginatorsSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="getOriginators">
      <soap:operation soapAction="http://tempuri.org/getOriginators" 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="GetOriginatorsSoap12" type="tns:GetOriginatorsSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="getOriginators">
      <soap12:operation soapAction="http://tempuri.org/getOriginators" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="GetOriginatorsHttpGet" type="tns:GetOriginatorsHttpGet">
    <http:binding verb="GET" />
    <wsdl:operation name="getOriginators">
      <http:operation location="/getOriginators" />
      <wsdl:input>
        <http:urlEncoded />
      </wsdl:input>
      <wsdl:output>
        <mime:mimeXml part="Body" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="GetOriginatorsHttpPost" type="tns:GetOriginatorsHttpPost">
    <http:binding verb="POST" />
    <wsdl:operation name="getOriginators">
      <http:operation location="/getOriginators" />
      <wsdl:input>
        <mime:content type="application/x-www-form-urlencoded" />
      </wsdl:input>
      <wsdl:output>
        <mime:mimeXml part="Body" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="GetOriginators">
    <wsdl:port name="GetOriginatorsSoap" binding="tns:GetOriginatorsSoap">
      <soap:address location="pathofws" />
    </wsdl:port>
    <wsdl:port name="GetOriginatorsSoap12" binding="tns:GetOriginatorsSoap12">
      <soap12:address location="pathofws" />
    </wsdl:port>
    <wsdl:port name="GetOriginatorsHttpGet" binding="tns:GetOriginatorsHttpGet">
      <http:address location="pathofws" />
    </wsdl:port>
    <wsdl:port name="GetOriginatorsHttpPost" binding="tns:GetOriginatorsHttpPost">
      <http:address location="pathofws" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Это пример кода клиента:

      GetOriginator.GetOriginators getOri = new Entegrasyon.GetOriginator.GetOriginators();

      ...
      ...

        String retxml ="";//return xml
        try
        {
            //Gönderelim    
             retxml = getOri.getOriginators(xml);
        }
        catch (Exception exp)
        {
            exp.ToString();
            //http 415
        }

Я могу только подтвердить отправку запросов через CURL, возвращая успешные ответы. Вот моя просьба.

curl -X POST -d xml = "некоторый допустимый xml" myWSaddress --header "Тип содержимого:application/x-www-form-urlencoded" -k

или сделать запрос GET через адресную строку веб-браузера тоже хорошо.

https://mywsadress/?xml='valid xml'

Можете ли вы помочь мне, пожалуйста, почему я не могу делать успешные запросы? Я попытался изменить значение @Consumes в коде WS, попробовал несколько разных типов, но все они потерпели неудачу.

edit: base {System.Exception} = {"Метод может быть вызван только для типа, для которого Type.IsGenericParameter имеет значение true."} это то, что я вижу, когда смотрю глубже в объект исключения в C Sharp.

0 ответов

Другие вопросы по тегам