Forum Discussion

quickbridge's avatar
quickbridge
New Contributor
16 years ago

Bad request on Localhost webservice

Hi,

I've downloaded soapUI and followed the "Getting Started" using a publically available webservice, and it works fine.

So I've added a new project using a service that I really want to test, which is running on my machine:  http://localhost:2222/caiWS.asmx. If I browse to the service in IE, and pick a method I can use the test page to post a request and everything works fine, but if I create a default request against the service, take the exact same XML, and put it in the that SoapUI creates, I get a "HTTP/1.1 400 Bad Request"

Any ideas what I'm doing wrong?

Thanks
  • Hi!

    hmm.. can you attach the WSDL for your service and the request you are trying to send?

    regards!

    /Ole
    eviware.com
  •   <?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://RedlineApplicationServices.com/CognitionAI/" 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://RedlineApplicationServices.com/CognitionAI/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    - <wsdl:types>
    - <s:schema elementFormDefault="qualified" targetNamespace="http://RedlineApplicationServices.com/CognitionAI/">
    - <s:element name="AccountInteraction">
    - <s:complexType>
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="request" type="s:string" />
      </s:sequence>
      </s:complexType>
      </s:element>
    - <s:element name="AccountInteractionResponse">
    - <s:complexType>
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="AccountInteractionResult" type="s:string" />
      </s:sequence>
      </s:complexType>
      </s:element>
      <s:element name="MessageHeader" type="tns:MessageHeader" />
    - <s:complexType name="MessageHeader">
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="MessageID" type="s:string" />
      </s:sequence>
      <s:anyAttribute />
      </s:complexType>
    - <s:element name="CardInteraction">
    - <s:complexType>
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="request" type="s:string" />
      </s:sequence>
      </s:complexType>
      </s:element>
    - <s:element name="CardInteractionResponse">
    - <s:complexType>
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="CardInteractionResult" type="s:string" />
      </s:sequence>
      </s:complexType>
      </s:element>
      </s:schema>
      </wsdl:types>
    - <wsdl:message name="AccountInteractionSoapIn">
      <wsdl:part name="parameters" element="tns:AccountInteraction" />
      </wsdl:message>
    - <wsdl:message name="AccountInteractionSoapOut">
      <wsdl:part name="parameters" element="tns:AccountInteractionResponse" />
      </wsdl:message>
    - <wsdl:message name="AccountInteractionMessageHeader">
      <wsdl:part name="MessageHeader" element="tns:MessageHeader" />
      </wsdl:message>
    - <wsdl:message name="CardInteractionSoapIn">
      <wsdl:part name="parameters" element="tns:CardInteraction" />
      </wsdl:message>
    - <wsdl:message name="CardInteractionSoapOut">
      <wsdl:part name="parameters" element="tns:CardInteractionResponse" />
      </wsdl:message>
    - <wsdl:message name="CardInteractionMessageHeader">
      <wsdl:part name="MessageHeader" element="tns:MessageHeader" />
      </wsdl:message>
    - <wsdl:portType name="caiWSSoap">
    - <wsdl:operation name="AccountInteraction">
      <wsdl:input message="tns:AccountInteractionSoapIn" />
      <wsdl:output message="tns:AccountInteractionSoapOut" />
      </wsdl:operation>
    - <wsdl:operation name="CardInteraction">
      <wsdl:input message="tns:CardInteractionSoapIn" />
      <wsdl:output message="tns:CardInteractionSoapOut" />
      </wsdl:operation>
      </wsdl:portType>
    - <wsdl:binding name="caiWSSoap" type="tns:caiWSSoap">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    - <wsdl:operation name="AccountInteraction">
      <soap:operation soapAction="http://RedlineApplicationServices.com/CognitionAI/AccountInteraction" style="document" />
    - <wsdl:input>
      <soap:body use="literal" />
      <soap:header message="tns:AccountInteractionMessageHeader" part="MessageHeader" use="literal" />
      </wsdl:input>
    - <wsdl:output>
      <soap:body use="literal" />
      <soap:header message="tns:AccountInteractionMessageHeader" part="MessageHeader" use="literal" />
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="CardInteraction">
      <soap:operation soapAction="http://RedlineApplicationServices.com/CognitionAI/CardInteraction" style="document" />
    - <wsdl:input>
      <soap:body use="literal" />
      <soap:header message="tns:CardInteractionMessageHeader" part="MessageHeader" use="literal" />
      </wsdl:input>
    - <wsdl:output>
      <soap:body use="literal" />
      <soap:header message="tns:CardInteractionMessageHeader" part="MessageHeader" use="literal" />
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
    - <wsdl:binding name="caiWSSoap12" type="tns:caiWSSoap">
      <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    - <wsdl:operation name="AccountInteraction">
      <soap12:operation soapAction="http://RedlineApplicationServices.com/CognitionAI/AccountInteraction" style="document" />
    - <wsdl:input>
      <soap12:body use="literal" />
      <soap12:header message="tns:AccountInteractionMessageHeader" part="MessageHeader" use="literal" />
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" />
      <soap12:header message="tns:AccountInteractionMessageHeader" part="MessageHeader" use="literal" />
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="CardInteraction">
      <soap12:operation soapAction="http://RedlineApplicationServices.com/CognitionAI/CardInteraction" style="document" />
    - <wsdl:input>
      <soap12:body use="literal" />
      <soap12:header message="tns:CardInteractionMessageHeader" part="MessageHeader" use="literal" />
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" />
      <soap12:header message="tns:CardInteractionMessageHeader" part="MessageHeader" use="literal" />
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
    - <wsdl:service name="caiWS">
    - <wsdl:port name="caiWSSoap" binding="tns:caiWSSoap">
      <soap:address location="http://localhost:2222/caiWS.asmx" />
      </wsdl:port>
    - <wsdl:port name="caiWSSoap12" binding="tns:caiWSSoap12">
      <soap12:address location="http://localhost:2222/caiWS.asmx" />
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>


    and


    <AccountInformationRequest xmlns="http://RedlineApplicationServices.com/CognitionAI/AccountInformationRequest.xsd">
        <Authentication>
            <LoginName>WWWWWW</LoginName>
            <Password>KKKKKKK</Password>
        </Authentication>
        <Directives>
            <Environment>TRIAL</Environment>
            <RequestedAction>AccountSummary</RequestedAction>
            <CustomerReference>77777</CustomerReference>
            <AccountReference>000000111111</AccountReference>
        </Directives>
    </AccountInformationRequest>


    Thanks

    Chris
  • Hi Chris?

    Is this the entire request? It should be surrounded by SOAP Envelope and Body elements..

    regards!

    /Ole
    eviware.com
  • Oh, sorry that's the XML I'm putting in the request.

    The generated default request is

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cog="http://RedlineApplicationServices.com/CognitionAI/">
       <soapenv:Header>
          <cog:MessageHeader>
              <!--Optional:-->
              <cog:MessageID>?</cog:MessageID>
          </cog:MessageHeader>
       </soapenv:Header>
       <soapenv:Body>
          <cog:AccountInteraction>
             <!--Optional:-->
             <cog:request>?</cog:request>
          </cog:AccountInteraction>
       </soapenv:Body>
    </soapenv:Envelope>


    so I'm taking out the optional MessageID element in the header and putting my XML into the request section, which gives

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cog="http://RedlineApplicationServices.com/CognitionAI/">
       <soapenv:Header>
          <cog:MessageHeader>
          </cog:MessageHeader>
       </soapenv:Header>
       <soapenv:Body>
          <cog:AccountInteraction>
             <!--Optional:-->
             <cog:request>
    <AccountInformationRequest xmlns="http://RedlineApplicationServices.com/CognitionAI/AccountInformationRequest.xsd">
        <Authentication>
    <LoginName>WWWWWW</LoginName>
    <Password>KKKKKKK</Password>
        </Authentication>
        <Directives>
    <Environment>TRIAL</Environment>
    <RequestedAction>AccountSummary</RequestedAction>
    <CustomerReference>77777</CustomerReference>
    <AccountReference>000000111111</AccountReference>
        </Directives>
    </AccountInformationRequest>
             </cog:request>
          </cog:AccountInteraction>
       </soapenv:Body>
    </soapenv:Envelope>


    Am I doing it wrong?

    Thanks

    Chris
  • Hi Chris,

    hmm.. maybe the XML you are inserting is to sent as a string and not as XML, try surrounding it with a CDATA section as follows:


     

         
         

     

     
         
           
            </b><AccountInformationRequest xmlns="http://RedlineApplicationServices.com/CognitionAI/AccountInformationRequest.xsd"><br /> &nbsp; &nbsp; <Authentication><br /> <LoginName>WWWWWW</LoginName><br /> <Password>KKKKKKK</Password><br /> &nbsp; &nbsp; </Authentication><br /> &nbsp; &nbsp; <Directives><br /> <Environment>TRIAL</Environment><br /> <RequestedAction>AccountSummary</RequestedAction><br /> <CustomerReference>77777</CustomerReference><br /> <AccountReference>000000111111</AccountReference><br /> &nbsp; &nbsp; </Directives><br /> </AccountInformationRequest><b>
         

     


    Does that make any difference?

    regards,

    /Ole
    eviware.com
  • Hi,
    I'm unable to add the custom headers. For example in this request there is a header
         
             
              ?
         


    How to add this to soap request in SOAPUI?.

    I'm using the soapUI version 3.0.1

    thanks in advance,
    VK