All , I had a JBoss application which uses apache-common-fileupload component, I had tested it can be uploaded large file from a asp.net Client which use HttpWebRequest in post method. But after several times of successful upload.It failed with a exception below in JBoss console. Please help to check it .Thanks.
org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:359)
at com.accela.deploy.servlet.RequestHandler.getUploadFileFromRequest(RequestHandler.java:86)
at com.accela.deploy.servlet.DeployServlet.doPost(DeployServlet.java:122)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.accela.commom.filter.AuthFilter.doFilter(AuthFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:615)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1733)
at java.lang.Thread.run(Thread.java:722)
Here is the server.xml content. Please check it .
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<Service name="jboss.web">
<!-- A HTTP/1.1 Connector (Http11Protocol Http11NioProtocol Http11AprProtocol)-->
<Connector protocol="org.apache.coyote.http11.Http11AprProtocol"
address="${jboss.bind.address}" port="${av.http.port}"
scheme="http" secure="false"
URIEncoding="UTF-8"
redirectPort="${av.https.port}"
maxHttpHeaderSize="8192"
maxThreads="${av.http.maxThreads:500}"
acceptCount="${av.http.acceptCount:200}"
enableLookups="false"
disableUploadTimeout="true"
/>
<!-- Java SSL Coyote HTTP/1.1 Connector using Apache Portable Runtime (APR) -->
<Connector protocol="org.apache.coyote.http11.Http11AprProtocol"
address="${jboss.bind.address}" port="${av.https.port}"
scheme="https" secure="true"
URIEncoding="UTF-8"
maxHttpHeaderSize="8192"
maxThreads="${av.https.maxThreads:500}"
acceptCount="${av.https.acceptCount:200}"
enableLookups="false"
disableUploadTimeout="true"
SSLEnabled="true"
SSLVerifyClient="none"
SSLProtocol="all"
SSLCipherSuite="!aNULL:!ADH:!eNULL:!LOW:!EXP:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:ALL"
SSLCertificateFile="${jboss.server.home.dir}/conf/certs/${av.host}.crt"
SSLCertificateKeyFile="${jboss.server.home.dir}/conf/certs/${av.host}.key"
/>
<Engine name="jboss.web" defaultHost="localhost">
<Realm className="org.jboss.web.tomcat.security.JBossSecurityMgrRealm"
certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
allRolesMode="authOnly"
/>
<Host name="localhost"
autoDeploy="false" deployOnStartup="false" deployXML="false"
configClass="org.jboss.web.tomcat.security.config.JBossContextConfig">
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="av.web.${jboss.bind.address}.access."
suffix=".log"
pattern="%a %t %T "%r" %s %b %u %S %p"
directory="${jboss.server.log.dir}"
resolveHosts="false" />
<Valve className="org.jboss.web.tomcat.service.sso.ClusteredSingleSignOn" />
-->
<!-- Check for unclosed connections and transaction terminated checks
in servlets/jsps.
Important: The dependency on the CachedConnectionManager
in META-INF/jboss-service.xml must be uncommented, too
-->
<Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve"
cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"
transactionManagerObjectName="jboss:service=TransactionManager" />
</Host>
</Engine>
</Service>
Edited and Added Asp.net client code .
public static bool SendSingleChunk(string sRequestUrl,int iOffset, int iChunkSize)
{
string sPackFullUriName = "d:\\2GB.zip";
string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("--" + boundary + "\r\n");
string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n"
+ "Content-Type: application/octet-stream\r\n\r\n";
sFName = Path.GetFileName(sPackFullUriName);
string header = string.Format(headerTemplate, sFName, sPackFullUriName);
byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
byte[] endBoundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
Stream requestStream = null;
HttpWebRequest request = null;
byte[] bData = null;
try
{
bData = StorageHelper.ChunkReadFromDiskFile(sPackFullUriName, iOffset, iChunkSize);
Log.Write("This is the " + iChunkindex + " times to send chunk, size is " + bData.Length.ToString());
long lContentLen = bData.Length + boundarybytes.Length + headerbytes.Length + endBoundarybytes.Length;
string sContentType = "multipart/form-data; boundary=" + boundary;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(sRequestUrl);
request.Method = WebRequestMethods.Http.Post;
request.KeepAlive = false;
request.Timeout = 300 * 60 * 1000; //300 mins;
request.ContentLength = lContentLen;
request.AllowAutoRedirect = false;
request.ContentType = sContentType;
using (requestStream = request.GetRequestStream())
{
requestStream.Write(boundarybytes, 0, boundarybytes.Length);
requestStream.Write(headerbytes, 0, headerbytes.Length);
if (bData != null)
{
requestStream.Write(bData, 0, bData.Length);
}
else
{
return false;
}
//requestStream.Write(formitembytes, 0, formitembytes.Length);
requestStream.Write(endBoundarybytes, 0, endBoundarybytes.Length);
requestStream.Flush();
requestStream.Close();
}
string returnedContent = string.Empty;
using (var response = (HttpWebResponse)request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(responseStream))
{
returnedContent = reader.ReadToEnd();
reader.Close();
}
}
response.Close();
if (DeployConfig.ResultSucceed.Equals("OK", StringComparison.InvariantCultureIgnoreCase))
{
return true;
}
else
{
return false;
}
}
}
catch (Exception ex)
{
return false;
}
finally
{
bData = null;
}
}
My idea:
I believe the root reason of the Stream ended unexpectedly exception is the length of the stream I post to server is not exactly equal to the length i specified in the HttpWebRequest.ContentLength.
My Questions:
1.What if the the length of the HttpWebRequest.ContentLength is larger or smaller than the actual size of I sent to server ?
2.What if I continue to execute SendSingleChunk after a failed post ? It seems the server recognized these two request streams as the same one.
The error message says:
.. Stream ended unexpectedly
This is most probably because the asp.net client application closes the socket unexpectedly after several successful uploads or may be there is a connection problem. Please see the below thread for a full discussion on the possible reasons for this error.
Why did I get "FileUploadException: Stream ended unexpectedly" with Apache Commons FileUpload?
All, For the upload large file issue , Here are some tips we should care about .
Whatever the webserver you used, actually in the process of uploading file from a certain of client to it, The first thing after receive data which it have to do is persist the data to some temporary directory. so, firstly make sure the application in the server have the enough privilege to write data to the disk.
Secondly. If we upload the file with underlying html protocol just like what I did.
We should check the protocol carefully, make sure every steps following the protocol. here is the doc for it .
The last thing I want to say is if you use the asp.net as a web client for some purpose, you must carefully check out what these property of HttpWebRequest use for. thanks.
request.KeepAlive = false;
request.Timeout = 300 * 60 * 1000; //300 mins;
request.ContentLength = lContentLen;
request.AllowAutoRedirect = false;
Related
I am hosting webservice using mule 3.6.
I observed POST HTTP request is working fine with java client. But C# client this webservice is getting called intermittently i.e first call is ok, second time out , third call is ok , fourth time out and so on.
GET HTTP request is working fine with C# client
Below is the sample of mule-flow.xml
<http:listener-config name="Port1_WS_Listener" host="0.0.0.0" port="7001" doc:name="WS Listener">
<http:worker-threading-profile maxThreadsActive="20" maxThreadsIdle="10" threadTTL="10000" threadWaitTimeout="5000"/>
</http:listener-config>
<http:listener-config name="Port2_WS_Listener" host="0.0.0.0" port="7002" doc:name="WS Listener">
<http:worker-threading-profile maxThreadsActive="20" maxThreadsIdle="10" threadTTL="10000" threadWaitTimeout="5000"/>
</http:listener-config>
<flow name="WSFlow">
<composite-source>
<http:listener config-ref="Port1_WS_Listener" path="getAttributes1"
doc:name="Port1 " allowedMethods="POST"/>
<http:listener config-ref="Port2_WS_Listener" path="getAttributes2"
doc:name="Port2" allowedMethods="POST"/>
</composite-source>
<component doc:name="java : WSHandler">
<interceptor-stack ref="default" />
<spring-object bean="httpWSHandler" />
</component>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<logger level="ERROR" message="#[exception]" doc:name="Logger" />
</catch-exception-strategy>
</flow>
C# client sample code
poststring value would be like param=[{'empId':'123', 'empName':'xyz'}]
WebRequest webRequest = (HttpWebRequest)WebRequest.Create(requestUrl);
webRequest.Method = "POST";
webRequest.Timeout = Timeout;
byte[] postBytes = Encoding.UTF8.GetBytes(postString);
webRequest.ContentType = "application/x-www-form-urlencoded";
StreamWriter writer = new StreamWriter(webRequest.GetRequestStream());
writer.WriteLine(postString);
writer.Close();
WebResponse wsResponse = webRequest.GetResponse();
Console.WriteLine("Response Successful");
Stream dataStream = wsResponse.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string response = reader.ReadToEnd();
dataStream.Close();
Console.WriteLine("Response Closed");
Curl output
Note: in below out parameter value has been replaced with dummy parameter hence content length value may differ
About to connect() to localhost port 7002
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 7002
> POST /getAttributes2 HTTP/1.1
> User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8
> Host: localhost:7002
> Accept: */*
> Content-Length: 417
> Content-Type: application/x-www-form-urlencoded
>
> param=[{'empId':'123', 'empName':'xyz'}]HTTP/1.1 200
< MULE_ENCODING: US-ASCII
< Content-Length: 719
< Date: Fri, 31 Jul 2015 09:19:20 GMT
Connection #0 to host localhost left intact
* Closing connection #0
[{"company":"xyz","department":"xyz"}]
I have figured out solution , seems we need to use http-proxy like below
HTTP Proxy
<pattern:http-proxy name="http-proxy-sample">
<http:inbound-endpoint address="http://0.0.0.0:10011/getEmployeeAttributesProxy" />
<http:outbound-endpoint address="http://0.0.0.0:10001/getEmployeeAttributes" />
</pattern:http-proxy>
I experienced the same problem with C# HTTP POST requests going through the APIKit to the new HTTP Listener to the same flow in rapid succession. I worked around it by switching back to the deprecated HTTP Inbound Endpoint, where it is not a problem.
<http:inbound-endpoint doc:name="HTTP" exchange-pattern="request-response" path="api/v1/" host="${http.cs-testing-tools.host}" port="${http.cs-testing-tools.port}" />
When monitoring the flows using Mule Management Console, the calls which timeout are never registered by Mule, so it appears that the HTTP listener never gets a payload to process.
Nov 18 2015 UPDATE - After some discussion with Mule support, this is caused by the interaction between C# and the library used by the new HTTP Listener. The behavior manifests as every other POST timing out.
You can work around this on the C# side as follows:
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ServicePoint.Expect100Continue = false;
You can add Settings to app.config or web.config in your C# project
<system.net>
<settings>
<servicePointManager expect100Continue="false"/>
</settings>
</system.net>
I am new to Anypoint Studio and I am trying to create a flow that will have an HTTP connector and an endpoint and when a user invokes the http endpoint then the application will load the contents of an XML file, will convert then to JSON and will return the JSON back in the HTTP Response.
My flow configuration looks like this
<flow name="test-flow">
<http:listener config-ref="HttpListenerConfiguration" path="/read" allowedMethods="POST" doc:name="HTTP">
<http:response-builder statusCode="200">
<http:header headerName="Content-Type" value="application/json"/>
</http:response-builder>
</http:listener>
<file:inbound-endpoint path="xml/test.xml" responseTimeout="10000" doc:name="File"/>
<mulexml:xml-to-object-transformer returnClass="org.mule.examples.Catalog" doc:name="XML to Object"/>
<json:object-to-json-transformer sourceClass="org.mule.examples.Catalog" doc:name="Object to JSON"/>
</flow>
Of course it doesn't work. I get a
SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'file:inbound-endpoint'. One of '{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-outbound-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor, "http://www.mulesoft.org/schema/mule/core":response}' is expected.
which I assume is coming from the fact that <file:inbound-endpoint...> needs to be as a source in the flow.
Any suggestions on how can I read a file after an HTTP endpoint is invoked?
Thanks
As you correctly assumed, file:inbound-endpoint can only act as a message source. Thus to achieve what you want you can use the mule module requester. HTH.
Try the requester module. It will allow you to load the file at any point in the flow. You can read more about it in this blogpost.
Also you can use XML to Json inbuilt transformer in to convert it to a Json object.
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="test-flow1">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<json:xml-to-json-transformer doc:name="XML to JSON"/>
<logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
</flow>
If the XML file is on the classpath, you might try <parse-template location="xml/test.xml"> instead of your <file:inbound-endpoint />
The parse-template processor comes in handy surprisingly often. The User's Guide also has a nice reference for it.
You can also write a java component to read the content of the file and use that component in the flow.
Example:
public class FileReaderComponent implements Callable, Initialisable {
private String filePath;
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
#Override
public void initialise() throws InitialisationException {
if (filePath == null || filePath.equals("")) {
throw new InitialisationException(MessageFactory.createStaticMessage("FilePath property has to be set"), this);
}
}
#Override
public Object onCall(MuleEventContext eventContext) throws Exception {
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(new File(filePath)));
} catch (Exception e) {
//Handle Exception
}
StringBuilder content = new StringBuilder();
try {
String line;
while ((line = in.readLine()) != null) {
content.append(line);
}
}catch (Exception e) {
//Handle Exception
} finally {
in.close();
}
return content.toString();
}
}
As many suggested in above, you can use java component or some kind of parse template.
We also had same kind of requirement , we used the expression component to read the file from particular location
I use mule to process the files from sftp, but I need to process the file in order(the sequence is order by name of file).
For example:
there are 3 files in sftp:
1.txt,2.txt,3.txt
I need to process these three files one by one and have to in the order of file's name.(first to process 1.txt then 2.txt at last 3.txt)
I use service-overrides in connector and extend the SftpMessageReceiver and override the poll() method ,in the method I make these files's name by order. But it doesn't work.Who can tell me where is wrong.
the class I write
public class NewSftpMessageReceiver extends SftpMessageReceiver {
private SftpReceiverRequesterUtil sftpRRUtil = null;
public NewSftpMessageReceiver(SftpConnector connector,
FlowConstruct flow,
InboundEndpoint endpoint,
long frequency) throws
CreateException {
super(connector, flow, endpoint);
this.setFrequency(frequency);
sftpRRUtil = new SftpReceiverRequesterUtil(endpoint);
}
public NewSftpMessageReceiver(SftpConnector connector, FlowConstruct flow, InboundEndpoint endpoint)
throws
CreateException {
super(connector, flow, endpoint);
sftpRRUtil = new SftpReceiverRequesterUtil(endpoint);
}
#Override
public void poll() throws
Exception {
try {
String[] files = sftpRRUtil.getAvailableFiles(false);
//do something here.....
for (String file : files) {
if (getLifecycleState().isStopping()) {
break;
}
routeFile(file);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
the config file like below
<sftp:connector name="incoming-mandate-connector"
archiveDir="${esb.archive.path}/mandate/incoming"
useTempFileTimestampSuffix="true"
autoDelete="true"
identityFile="${esb.incoming.sftp.identityFile}"
passphrase="${esb.incoming.sftp.passphrase}"
sizeCheckWaitTime="${esb.incoming.sftp.sizeCheckWaitTime}">
<service-overrides messageReceiver="com.xxy.NewSftpMessageReceiver"/>
</sftp:connector>
<sftp:endpoint name="incoming-mandate-ep"
address="${esb.incoming.connector}"
connector-ref="incoming-mandate-connector"
keepFileOnError="true" encoding="${esb.encoding}">
<file:filename-wildcard-filter pattern="${esb.incoming.filePattern}"/>
</sftp:endpoint>
the flow like blew
<flow name="process">
<quartz:inbound-endpoint name="quartz-endpoint" cronExpression="${esb.cronExpression}" jobName="incoming-mandate-job">
<quartz:endpoint-polling-job>
<quartz:job-endpoint ref="incoming-mandate-ep"/>
</quartz:endpoint-polling-job>
</quartz:inbound-endpoint>
<processor ref="mandate-processor"/>
<transformer ref="mandate-transformer"/>
<mulexml:jaxb-object-to-xml-transformer jaxbContext-ref="jaxb" name="mandate-jaxb-transformer"/>
<byte-array-to-string-transformer mimeType="application/xml"/>
<message-properties-transformer scope="outbound">
<add-message-property key="${esb.username}" value="${esb.password}"/>
</message-properties-transformer>
<outbound-endpoint ref= "mandate-service-ep"/>
</flow>
The reason why your message receiver is not being called is because you have a Quartz endpoint that calls the SFTP transport, so in fact you are using a message requester, not a receiver.
You would need to create a custom message requester instead of a receiver and also a custom requester factory (that creates instances of the requester)
You can configure it as follows:
<sftp:connector name="sftpConnector">
<spring:property name="serviceOverrides">
<spring:map>
<spring:entry key="requester.factory" value="your.package.YourCustomSftpRequesterFactory"/>
</spring:map>
</spring:property>
</ftp:connector>
I was able to retrieve, decode the security token (SWT) from various identity providers configured in ACS. Now I should be - according to example - able to do this:
String headerValue = string.Format("WRAP access_token=\"{0}\"", securityToken);
WebClient client = new WebClient();
client.Headers.Add("Authorization", headerValue);
using (Stream stream = client.OpenRead(#"http://xxx.cloudapp.net/xxx.svc/users"))
using (StreamReader reader = new StreamReader(stream))
{
String response = reader.ReadToEnd();
}
It works in a sense it fails for a non-existing endpoint for example. So service is there (secured), token module and token validator on the server side are called, and token passes through. So it's not that. But anyway the problem is that the response contains HTML of a login page (that one with identity provider list in it). It seem like as though the token validation was OK, it still isn't enough for security.
What should I do now, to receive my data from a service? Any hints?
Scenario: http://tinyurl.com/WcfRestSaml
Update: I've included link to a picture of scenario I'm trying to achieve.
Update 2: OK, I've switched to Saml2, but same error has occured. Then I've found out I need assertion to receive access token. So I did:
WebClient client = new WebClient { BaseAddress = string.Format("https://{namespace}.accesscontrol.windows.net") };
NameValueCollection parameters = new NameValueCollection
{
{ "wrap_assertion_format", "SAML" },
{ "wrap_assertion", securityToken },
{ "wrap_scope", "http://{our}.cloudapp.net/" }
};
Byte[] responseBytes = client.UploadValues("WRAPv0.9", parameters);
String response = Encoding.UTF8.GetString(responseBytes);
This returns yet another error as well though:
Error:Code:401:SubCode:T0:Detail:ACS50008: SAML token is
invalid.:TraceID:1d3774fa-a5e6-3e3b-a5e5-5a0bde6e0771:TimeStamp:2013-06-06
16:18:05Z
But it seems that this should return my desired access token.
Update 3: Nothing helps, nowhere to gather the information, damn. I'm posting a full token on a blind chance somebody will notice something is wrong at least (I've removed sensitive informations though).
<Assertion ID="_541a71ba-1e00-478c-8d2b-0beac3a35d35" IssueInstant="2013-06-07T11:38:31.741Z" Version="2.0" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
<Issuer>https://{removed}.accesscontrol.windows.net/</Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
<ds:Reference URI="#_541a71ba-1e00-478c-8d2b-0beac3a35d35">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
<ds:DigestValue>{removed}</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>{removed}</ds:SignatureValue>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<X509Data>
<X509Certificate>{removed}</X509Certificate>
</X509Data>
</KeyInfo>
</ds:Signature>
<Subject>
<NameID>https://www.google.com/accounts/o8/id?id={removed}</NameID>
<SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer" />
</Subject>
<Conditions NotBefore="2013-06-07T11:38:31.694Z" NotOnOrAfter="2013-06-07T12:38:31.694Z">
<AudienceRestriction>
<Audience>http://{removed}.cloudapp.net/</Audience>
</AudienceRestriction>
</Conditions>
<AttributeStatement>
<Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress">
<AttributeValue>{removed}</AttributeValue>
<AttributeValue>https://www.google.com/accounts/o8/id?id={removed}</AttributeValue>
<AttributeValue>{removed}</AttributeValue>
</Attribute>
<Attribute Name="http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider">
<AttributeValue>Google</AttributeValue>
</Attribute>
</AttributeStatement>
</Assertion>
As noted above:
We've solved it with Microsoft Support, it was caused by the fact, the service was behind passive federation, and the process doesn't like obviously. I've solved it by creating a <RequestSecurityToken> envelope for the SAML2 assertion token, this way it "simulated" browser activity, and it works well and also plays well with passive federation (due to WS-TRUST envelope).
It needed to pass it first and then it connected to ACS.The problem wasn't in access token or SAML assertion at all. It was caused - as I've pointed out - by the fact that part of website was behind the custom STS federation. The WS Federation module was blocking reception of this token. When I enveloped it in RequestSecurityToken for WS Federation to chew on first. It then passed to ACS as presented in my question.
I am trying to consume this service that requires wsse header as
<soapenv:Header>
<wsse:Security soapenv:actor="AppID" soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>domain1\UNM1</wsse:Username>
<wsse:Password wsse:Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PWD1</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
I am creating proxy dynamically as
string[] assemblyReferences = new string[3] { "System.Web.Services.dll", "System.Xml.dll", "Microsoft.Web.Services3.dll" };
CompilerParameters parms = new CompilerParameters(assemblyReferences);
CompilerResults results = provider1.CompileAssemblyFromDom(parms, unit1);
if (results.Errors.Count > 0)
{
foreach (CompilerError oops in results.Errors)
{
Console.WriteLine("========Compiler error============");
Console.WriteLine(oops.ErrorText);
}
return;
}
//Invoke the web service method
object o = results.CompiledAssembly.CreateInstance("DynamicServiceProxy.servicename");
//object o = results.CompiledAssembly.CreateInstance("DynamicServiceProxy.WebService");
Type t = o.GetType();
BindingFlags bf = BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.DeclaredOnly;
MethodInfo m = t.GetMethod("Methodname", bf);
stroutput = (string) m.Invoke(o, new object[].....
How do I pass header to this. I did some research and installed WSE 3.0 and added reference for service3. However i am not able to get RequestSoapContext or clientcredential method in t. client(o) is being generated from soaphttpclientprotocol and not WebServicesClientProtocol and that should be cause of all problems. Please help.
Also since generating proxy dynamically , not sure i can do like
MessageServiceWse client = new MessageServiceWse()
Also I am not sure about wsse type . How to define this.
Just to note that I am using VS 2010
This is my first service experience so please excuse me in case I did some obvious mistake(s).
Need expert help.
changed end point to include header as it is common across request.
<endpoint address="https://wsext.test.com/gfr/ext/test1/"
binding="basicHttpBinding" bindingConfiguration="GLEditServiceSOAP"
contract="test1.GLEditServicePort" name="GLEditServicePort">
<headers >
<wsse:Security s:actor="AppID" s:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<wsse:UsernameToken>
<wsse:Username>test1\testuserid</wsse:Username>
<wsse:Password wsse:Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</headers>
</endpoint>