日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

java soap协议头_java – 服务器无法识别HTTP标头“SOAPAction”的值

發布時間:2023/11/27 生活经验 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java soap协议头_java – 服务器无法识别HTTP标头“SOAPAction”的值 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

當我向服務器發送SOAP請求時,它返回以下錯誤,盡管我使用SoapUI發送類似請求并且可以正常工作.我似乎需要將我的SOAP請求更改為我使用SoapUI發送的請求. WSDL是here.

[ truncated ] System.Web.Services.Protocols.SoapException : The value of the

HTTP header ' SOAPAction ' was not recognized by the server . \ r \ n at

System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest ( )

\ r \ n at System.Web.Servic

我正在使用Java發送以下請求

MetaSearch>falseMetaSearch>

我可以使用SoapUI發送以下請求,它可以工作

MetaSearch>falseMetaSearch>

我不知道如何使用Java創建的請求與我使用SoapUI發送的請求相同.

SearchFlights

@XmlRootElement(name = "SearchFlights")

@XmlAccessorType(XmlAccessType.FIELD)

public class SearchFlights {

@XmlElement(name = "SoapMessage")

private SoapMessage soapMessage;

getter and setter

的SOAPMessage

@XmlRootElement(name = "SoapMessage")

@XmlAccessorType(XmlAccessType.FIELD)

public class SoapMessage {

@XmlElement(name = "Username")

private String username;

@XmlElement(name = "Password")

private String password;

@XmlElement(name = "LanguageCode")

private String languageCode;

@XmlElement(name = "Request")

private Request request;

getters and setters

請求

@XmlRootElement(name = "Request")

@XmlAccessorType(XmlAccessType.FIELD)

public class Request {

@XmlElement(name = "Departure")

private String departure;

@XmlElement(name = "Destination")

private String destination;

@XmlElement(name = "DepartureDate")

private String departureDate;

@XmlElement(name = "ReturnDate")

private String returnDate;

@XmlElement(name = "NumADT")

private int numADT;

@XmlElement(name = "NumINF")

private int numInf;

@XmlElement(name = "NumCHD")

private int numCHD;

@XmlElement(name = "CurrencyCode")

private String currencyCode;

@XmlElement(name = "WaitForResult")

private boolean waitForResult;

@XmlElement(name = "NearByDepartures")

private boolean nearByDepartures;

@XmlElement(name = "NearByDestinations")

private boolean nearByDestinations;

@XmlElement(name = "RROnly")

private boolean rronly;

@XmlElement(name = "MetaSearch")

private boolean MetaSearch;

getters and setters

package-info.java

@XmlSchema(

namespace = "ElsyArres.API",elementFormDefault = XmlNsForm.QUALIFIED)

package com.myproject.flights.wegolo;

import javax.xml.bind.annotation.XmlNsForm;

import javax.xml.bind.annotation.XmlSchema;

jaxb.in??dex

SearchFlights

Flight

Flights

Leg

Legs

Outbound

Request

Response

SoapMessage

代碼發送請求

import javax.xml.soap.MessageFactory;

import javax.xml.soap.SOAPConstants;

import org.springframework.oxm.jaxb.Jaxb2Marshaller;

import org.springframework.stereotype.Service;

import org.springframework.web.client.RestClientException;

import org.springframework.web.client.RestTemplate;

import org.springframework.ws.client.core.WebServiceTemplate;

import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;

......

// populate searchFlights and other classes to create request

try {

SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory(

MessageFactory.newInstance());

messageFactory.afterPropertiesSet();

WebServiceTemplate webServiceTemplate = new WebServiceTemplate(

messageFactory);

Jaxb2Marshaller marshaller = new Jaxb2Marshaller();

marshaller.setContextPath("com.myproject.flights.wegolo");

marshaller.afterPropertiesSet();

webServiceTemplate.setMarshaller(marshaller);

webServiceTemplate.afterPropertiesSet();

Response response = (Response) webServiceTemplate

.marshalSendAndReceive(

"http://www5v80.elsyarres.net/service.asmx",searchFlights);

Response msg = (Response) response;

System.err.println("Wegolo >>>"

+ msg.getFlights().getFlight().size());

} catch (Exception s) {

s.printStackTrace();

}

更新

我刪除了package-info.java并設法使用建議的代碼,但它仍然發送相同的標頭.

Response response = (Response) webServiceTemplate

.marshalSendAndReceive(

"http://www5v80.elsyarres.net/service.asmx",searchFlights,new WebServiceMessageCallback() {

public void doWithMessage(WebServiceMessage message)

{

((SoapMessage)message).setSoapAction("http://www5v80.elsyarres.net/searchFlights");

}

}

);

總結

以上是生活随笔為你收集整理的java soap协议头_java – 服务器无法识别HTTP标头“SOAPAction”的值的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。