我通过POSTMAN发送POST请求,但我的服务器(WebServer)正在接收它作为GET请求 - 任何人都可以想到为什么会发生这种情况?以下是邮递员的一些信息(匿名的URL /主机名的一部分):
POST /blaa/DescriptionEntities/description HTTP/1.1
Host: blaaa
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Postman-Token: 3901995b-78a0-598f-40d2-83b09e09d12e
id=20&description=hi
代码:
@POST
@Path("description")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public DescriptionEntity createDescriptionEntity(MultivaluedMap<String,String>map){
System.out.println(map.getFirst("id"));
System.out.println(map.getFirst("description"));
return null;
}
服务器(WebSphere):
No operation matching request path "/blaa/DescriptionEntities/description" is found, Relative Path: /description, HTTP Method: GET, ContentType: */*, Accept: */*,. Please enable FINE/TRACE log level for more details-is anyone able to kindly help here.
不确定如何在此处设置日志级别(我对此更新)。班级的相对路径是&#34; DescriptionEntities&#34;非常感谢。
编辑 - 这是整个班级(减去导入语句 - 它完全是实验性的,忽略了非相关错误):
@Path("DescriptionEntities")
public class DescriptionEntityResource {
private DescriptionEntityRepository descriptionEntityRepository=new DescriptionEntityRepository();
@Path("description")
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public DescriptionEntity createDescriptionEntity(MultivaluedMap<String,String>map){
System.out.println(map.getFirst("id"));
System.out.println(map.getFirst("description"));
return null;
}
}
Postman中的网址:http://blaa/DescriptionEntities/Description
编辑:Server.xml
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>jndi-1.0</feature>
<feature>json-1.0</feature>
<feature>localConnector-1.0</feature>
<feature>appSecurity-2.0</feature>
<feature>ssl-1.0</feature>
<feature>servlet-3.1</feature>
<feature>jaxrs-2.0</feature>
<feature>jpa-2.1</feature>
<feature>jsf-2.2</feature>
<feature>jsp-2.3</feature>
</featureManager>
<httpEndpoint host="*" httpPort="80" httpsPort="443" id="defaultHttpEndpoint" sslOptionsRef="endpointSSLOptions"/>
<sslOptions id="endpointSSLOptions" sslRef="endpointSSL"/>
<ssl enabledCiphers="TLS_RSA_WITH_AES_128_CBC_SHA TLS_RSA_WITH_AES_128_CBC_SHA256 " id="endpointSSL" keyStoreRef="customKeyStore"/>
<keyStore id="defaultKeyStore" password="annonymised"/>
<basicRegistry/>
<mimeTypes>
<type>svg=image/svg+xml</type>
</mimeTypes>
<httpSession useContextRootAsCookiePath="true" cookieSecure="true" />
<logging consoleLogLevel="INFO"/>
<applicationMonitor updateTrigger="mbean"/>
<webApplication id="annonymised" location="annonymised" name="annonymised"/>
编辑:网络流量(使用fiddler):
POST /blaa/DescriptionEntities/description HTTP/1.1
Host: blaa
Connection: keep-alive
Content-Length: 20
Cache-Control: no-cache
Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
编辑:GET请求:
GET /blaa/DescriptionEntities/description HTTP/1.1
Host: blaa
Connection: keep-alive
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Accept: */*
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: en-US,en;q=0.8
Cookie: IBMISP=b645ef125eca11e6aeed1341c031a83e- b645ef125eca11e6aeed1341c031a83e-0801740c1b0bc161a63c23e998bba6ec; CoreM_State=83~-1~-1~-1~-1~3~3~5~3~3~7~7~|~~|~~|~~|~||||||~|~~|~~|~~|~~|~~|~~|~~|~; CoreM_State_Content=6~|~~|~|; optimizelyEndUserId=oeu1470813611355r0.3187708418093793; ajs_user_id=null; ajs_group_id=null; amplitude_idibm.com=eyJkZXZpY2VJZCI6Ijk0ZGZlZWE0LTg4NjEtNDMzNi04Yzk5LWMyZWMwNjMxOGZmNFIiLCJ1c2VySWQiOm51bGwsIm9wdE91dCI6ZmFsc2UsInNlc3Npb25JZCI6MTQ3MDgxMzY4MDQ4MCwibGFzdEV2ZW50VGltZSI6MTQ3MDgxMzY4MDQ5MCwiZXZlbnRJZCI6MSwiaWRlbnRpZnlJZCI6MSwic2VxdWVuY2VOdW1iZXIiOjJ9; ajs_anonymous_id=%22b645ef125eca11e6aeed1341c031a83e%22; intercom-id=19922b40-fb41-4744-9dfb-89d6875c0294; UnicaNIODID=enSkfJ02Gh7-Z3dNjvn; optimizelySegments=%7B%222753990332%22%3A%22gc%22%2C%222757810742%22%3A%22search%22%2C%222762380326%22%3A%22false%22%2C%223081321317%22%3A%22none%22%2C%223855873690%22%3A%22referral%22%2C%223859505928%22%3A%22none%22%2C%223860673668%22%3A%22gc%22%2C%223861195110%22%3A%22false%22%7D; optimizelyBuckets=%7B%7D; cvo_sid1=EEHN9V3GC6UB; cvo_tid1=BF-jgeF2_Y4|1470813613|1471260957|0; mmcore.tst=0.794; mmapi.store.p.0=%7B%22mmparams.d%22%3A%7B%7D%2C%22mmparams.p%22%3A%7B%22mmid%22%3A%221502797170504%7C%5C%22716298243%7CCgAAAApStaCTtQ0AAA%3D%3D%5C%22%22%2C%22pd%22%3A%221502797170506%7C%5C%22-1893569528%7CCgAAAAoBQlK1oJO1DfyoSkgDAOpF09EAxdNIDwAAABoXwicJwdNIAAAAAP%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAZEaXJlY3QBtQ0DAAAAAAAAAAAAAP%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwAAAAAAAUU%3D%5C%22%22%2C%22srv%22%3A%221502797170510%7C%5C%22ldnvwcgus01%5C%22%22%7D%7D; __auc=f59597cf1567352a7c8a1f92cde; _ga=GA1.2.1447575942.1471939647; CoreID6=67988125510914708136127&ci=50200000|Bluemix_51040000|IBMTESTW3_51040000|HR_50200000|IBM_GlobalMarketing_50200000|devwrkscon_50200000|ESTKCS_50200000|DWNEXT; utag_main=v_id:01567352a47a000fc70d49709b1a04072002b06a00718$_sn:4$_ss:0$_st:1471941446924$dc_visit:4$_pn:7%3Bexp-session$ses_id:1471937020076%3Bexp-session$dc_event:19%3Bexp-session$dc_region:eu-central-1%3Bexp-session$ttd_uuid:f57e787f-a10b-48bc-833c-add2cf0e063d%3Bexp-session; 50200000_clogin=v=1&l=1471937020&e=1471941448777
编辑:我现在已经清除了这个小小的测试项目,因为我无法弄清楚什么是错的。我可能会再尝试另一次。仍然对于出了什么问题感到好奇,所以如果你发现任何明显的东西,请告诉我。谢谢大家