2014-04-16 12 views
9

Wysyłam żądanie SOAP jako HTTP POST w SOAPUI z powodu pewnych ograniczeń projektu. moja prośba jest tutaj:Nie otrzymałem błędu nagłówka SOAPAction podczas wysyłania żądania SOAP jako HTTP POST

POST httplink HTTP/1.1 
Accept-Encoding: gzip,deflate 
Content-Type: text/xml;charset=UTF-8 
SOAPAction: "urn:HPD_IncidentInterface_WS/HelpDesk_Query_Service" 
Content-Length: 725 
Host: itsm-mt-dev 
Connection: Keep-Alive 
User-Agent: Apache-HttpClient/4.1.1 (java 1.5) 


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:HPD_IncidentInterface_WS"> 
    <soapenv:Header> 
     <urn:AuthenticationInfo> 
     <urn:userName>XXXXXXXXXX</urn:userName> 
     <urn:password>XXXXXXXXX</urn:password> 
     <!--Optional:--> 
     <urn:authentication>?</urn:authentication> 
     <!--Optional:--> 
     <urn:locale>?</urn:locale> 
     <!--Optional:--> 
     <urn:timeZone>?</urn:timeZone> 
     </urn:AuthenticationInfo> 
    </soapenv:Header> 
    <soapenv:Body> 
     <urn:HelpDesk_Query_Service> 
     <urn:Incident_Number>XXXXXXXXXX</urn:Incident_Number> 
     </urn:HelpDesk_Query_Service> 
    </soapenv:Body> 
</soapenv:Envelope> 

Chociaż miałem ustawiony nagłówek SOAPAction, wciąż otrzymuję żadnego błędu nagłówka SoapAction.

Response następująco:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soapenv:Body> 
     <soapenv:Fault> 
     <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode> 
     <faultstring>no SOAPAction header!</faultstring> 
     <detail> 
      <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">itsm-mt-dev</ns2:hostname> 
     </detail> 
     </soapenv:Fault> 
    </soapenv:Body> 
</soapenv:Envelope> 

Czy ktoś może zasugerować mi, co możemy zrobić tutaj?

+0

W swoim wyglądzie WSDL dla linii, która wygląda mniej więcej tak ''. Co to jest soapAction dla operacji 'HelpDesk_Query_Service'? –

Odpowiedz

15

Wygląda na to, że wysyłasz nieprawidłowy nagłówek soapAction. Spójrz na WSDL i poznaj wartość dla elementu soapAction dla testowanej usługi.

W dokumencie WSDL poszukaj linii podobnej do <soap:operation soapAction="http://example.com/GetLastTradePrice"/>.

3
request.Headers.Add("SOAPAction", YOUR SOAP ACTION); 
+0

Utwórz httpwebrequest, a następnie dodaj do niego nagłówki: 'code'Dim bs = Kodowanie.UTF8.GetBytes (" soap ") Dim wr Jako HttpWebRequest = HttpWebRequest.Create (" xx ") wr.Headers.Add (" ur nagłówka mydła”, "XXX") wr.ContentType = "text/xml, charset = UTF-8" wr.Method = "POST" wr.ContentLength = bs.Length Dim SDS jako strumień = wr.GetRequestStream () sds.Write (bs, 0 bs.Length) sds.Close() Dim WR W WebResponse = wr.GetResponse() SDS = wr.GetResponseStream() Dim sr Jako StreamReader = Nowa StreamReader (SDS) DimstrResult As String = sr.ReadToEnd() txtResult .Text = strResult sds.Close() sr.Close() wr.Close() 'kod' –

0

Próbowałem dodać komentarz w odpowiedzi sugerowanej przez ynneh, ale kod nie był czytelny. Jego odpowiedź jest przydatna, ale jest za krótka.

Utwórz httpwebrequest, a następnie dodaj do niego nagłówki. po zakończeniu przykład:

Dim bytSoap = System.Text.Encoding.UTF8.GetBytes("soap content") 

     Dim wrRequest As HttpWebRequest = HttpWebRequest.Create("xxxxx") 

     wrRequest.Headers.Add("your soap header", "xxx") 

     wrRequest.ContentType = "text/xml; charset=utf-8" 
     wrRequest.Method = "POST" 
     wrRequest.ContentLength = bytSoap.Length 

     Dim sDataStream As Stream = wrRequest.GetRequestStream() 
     sDataStream.Write(bytSoap, 0, bytSoap.Length) 
     sDataStream.Close() 

     Dim wrResponse As WebResponse = wrRequest.GetResponse() 
     sDataStream = wrResponse.GetResponseStream() 
     Dim srReader As StreamReader = New StreamReader(sDataStream) 
     Dim strResult As String = srReader.ReadToEnd() 
     txtResult.Text = strResult 
     sDataStream.Close() 
     srReader.Close() 
     wrResponse.Close() 
0

// Delphi

var 
xmlhttp : IXMLHTTPRequest; // unit MSXML2_TLB 
begin 
xmlhttp := CoXMLHTTP.Create; 
xmlhttp.open('POST', Edit7.Text, False, EmptyParam, EmptyParam); 
xmlhttp.setRequestHeader('SOAPAction','POST') 
Powiązane problemy