http headers for c# client to Java Service
Hi ive been trying to add http headers to a webclient in c# , ive been looking alot of places and have had little luck often people point to a Credentials class however开发者_如何学JAVA i only have ClientCredentials my client also missing is a PreAuthenticate field?
The service is written in Java and I can add http headers to that as follows
reqHeaders.put(HEADER_NAME_USERNAME, Collections.singletonList(USER_NAME));
reqHeaders.put(HEADER_NAME_PASSWORD, Collections.singletonList(PASSWORD));
((BindingProvider) webWS).getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS,reqHeaders);
However i have no idea how to do this in c# ive tried endpoint address builder, ClientCredential, windows.ClientCredential basically anywehre i can find a username and passsword When i make a request in java i capture the http packet in wireshark looks kinds like this
+hypertext transfer protocol
+POST
post stuff
Password: mypass
Username: username
soapaction: ... and so on
i cant change the server side code all i know is if i can add two headers one called username and one password with values ill be Sheening (read:winning)
http://msmvps.com/blogs/paulomorgado/archive/2007/04/27/wcf-building-an-http-user-agent-message-inspector.aspx
This mostly answered my problem, instead of editing the app.config though i jsut added the newly defined behaviour class under
webservice.Endpoint.Behaviors.add(new CustomBehavior(params));
精彩评论